diff --git a/port/integration/resource_test.go b/port/integration/resource_test.go index 8899f9f5..c134e217 100644 --- a/port/integration/resource_test.go +++ b/port/integration/resource_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/port-labs/terraform-provider-port-labs/v2/internal/acctest" "github.com/port-labs/terraform-provider-port-labs/v2/internal/utils" ) @@ -164,6 +165,53 @@ func TestPortIntegrationPatchTitleNull(t *testing.T) { }) } +func TestPortIntegrationPatchIdentifierRequiresReplace(t *testing.T) { + integrationIdentifier := utils.GenID() + updatedIdentifier := utils.GenID() + installationAppType := "kafka" + err := os.Setenv("PORT_BETA_FEATURES_ENABLED", "true") + if err != nil { + t.Fatal(err) + } + var testPortIntegrationResourceBasic = createIntegration(integrationIdentifier, installationAppType) + + var testAccBaseIntegrationUpdate = strings.Replace(testPortIntegrationResourceBasic, integrationIdentifier, updatedIdentifier, -1) + + // var stepOneCreatedAt, stepTwoCreatedAt string + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.TestAccPreCheck(t) }, + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testPortIntegrationResourceBasic, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port_integration.kafkush", "installation_id", integrationIdentifier), + resource.TestCheckResourceAttr("port_integration.kafkush", "installation_app_type", installationAppType), + resource.TestCheckResourceAttr("port_integration.kafkush", "title", "my-kafka-cluster"), + resource.TestCheckResourceAttr("port_integration.kafkush", "version", "1.33.7"), + resource.TestCheckResourceAttr("port_integration.kafkush", "webhook_changelog_destination.%", "0"), + ), + }, + { + Config: testAccBaseIntegrationUpdate, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction("port_integration.kafkush", plancheck.ResourceActionDestroyBeforeCreate), + }, + }, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("port_integration.kafkush", "installation_id", updatedIdentifier), + resource.TestCheckResourceAttr("port_integration.kafkush", "installation_app_type", installationAppType), + resource.TestCheckResourceAttr("port_integration.kafkush", "title", "my-kafka-cluster"), + resource.TestCheckResourceAttr("port_integration.kafkush", "version", "1.33.7"), + resource.TestCheckResourceAttr("port_integration.kafkush", "webhook_changelog_destination.%", "0"), + ), + }, + }, + }) +} + func TestPortIntegrationWithWebhook(t *testing.T) { integrationIdentifier := utils.GenID() err := os.Setenv("PORT_BETA_FEATURES_ENABLED", "true") diff --git a/port/integration/schema.go b/port/integration/schema.go index 1adeadf0..7ff09982 100644 --- a/port/integration/schema.go +++ b/port/integration/schema.go @@ -6,6 +6,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" ) func IntegrationSchema() map[string]schema.Attribute { @@ -15,6 +17,9 @@ func IntegrationSchema() map[string]schema.Attribute { }, "installation_id": schema.StringAttribute{ Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, }, "version": schema.StringAttribute{ Optional: true,