@@ -22,6 +22,7 @@ import (
2222 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2323 "github.com/observiq/bindplane-op-enterprise/model"
2424 "github.com/observiq/terraform-provider-bindplane/client"
25+ "github.com/observiq/terraform-provider-bindplane/internal/component"
2526 "github.com/observiq/terraform-provider-bindplane/internal/parameter"
2627 "github.com/observiq/terraform-provider-bindplane/internal/resource"
2728)
@@ -87,8 +88,14 @@ func resourceDestinationCreate(d *schema.ResourceData, meta any) error {
8788 if c != nil {
8889 return fmt .Errorf ("destination with name '%s' already exists with id '%s'" , name , c .ID ())
8990 }
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 ())
9095 }
9196
97+ id := d .Id ()
98+
9299 parameters := []model.Parameter {}
93100 if s := d .Get ("parameters_json" ).(string ); s != "" {
94101 params , err := parameter .StringToParameter (s )
@@ -98,7 +105,7 @@ func resourceDestinationCreate(d *schema.ResourceData, meta any) error {
98105 parameters = params
99106 }
100107
101- r , err := resource .AnyResourceV1 (name , destType , model .KindDestination , parameters , nil )
108+ r , err := resource .AnyResourceV1 (id , name , destType , model .KindDestination , parameters , nil )
102109 if err != nil {
103110 return err
104111 }
0 commit comments