@@ -22,6 +22,7 @@ import (
22
22
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
23
23
"github.com/observiq/bindplane-op-enterprise/model"
24
24
"github.com/observiq/terraform-provider-bindplane/client"
25
+ "github.com/observiq/terraform-provider-bindplane/internal/component"
25
26
"github.com/observiq/terraform-provider-bindplane/internal/parameter"
26
27
"github.com/observiq/terraform-provider-bindplane/internal/resource"
27
28
)
@@ -87,8 +88,14 @@ func resourceDestinationCreate(d *schema.ResourceData, meta any) error {
87
88
if c != nil {
88
89
return fmt .Errorf ("destination with name '%s' already exists with id '%s'" , name , c .ID ())
89
90
}
91
+
92
+ // If a source does not already exist with this name
93
+ // and an ID is not set, generate and ID.
94
+ d .SetId (component .NewResourceID ())
90
95
}
91
96
97
+ id := d .Id ()
98
+
92
99
parameters := []model.Parameter {}
93
100
if s := d .Get ("parameters_json" ).(string ); s != "" {
94
101
params , err := parameter .StringToParameter (s )
@@ -98,7 +105,7 @@ func resourceDestinationCreate(d *schema.ResourceData, meta any) error {
98
105
parameters = params
99
106
}
100
107
101
- r , err := resource .AnyResourceV1 (name , destType , model .KindDestination , parameters , nil )
108
+ r , err := resource .AnyResourceV1 (id , name , destType , model .KindDestination , parameters , nil )
102
109
if err != nil {
103
110
return err
104
111
}
0 commit comments