From d5ec083e3c65181451060c8f1215f6becf7f0571 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 12:08:47 -0400 Subject: [PATCH 01/27] apigateway: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/apigateway/account_test.go | 39 ++++++++++++++++++- .../apigateway/base_path_mapping_test.go | 15 ++++++- .../service/apigateway/domain_name_test.go | 29 +++++++++++++- internal/service/apigateway/rest_api_test.go | 29 ++++++++++++-- 4 files changed, 104 insertions(+), 8 deletions(-) diff --git a/internal/service/apigateway/account_test.go b/internal/service/apigateway/account_test.go index 460ee67e7dd4..223d5ec85cb2 100644 --- a/internal/service/apigateway/account_test.go +++ b/internal/service/apigateway/account_test.go @@ -13,6 +13,7 @@ import ( sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" @@ -162,6 +163,11 @@ func testAccAccount_frameworkMigration_basic(t *testing.T) { }, }, Config: testAccAccountConfig_basic, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("cloudwatch_role_arn"), knownvalue.StringExact("")), }, @@ -169,7 +175,17 @@ func testAccAccount_frameworkMigration_basic(t *testing.T) { { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccAccountConfig_basic, - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("cloudwatch_role_arn"), knownvalue.StringExact("")), + }, }, }, }) @@ -195,6 +211,11 @@ func testAccAccount_frameworkMigration_cloudwatchRoleARN(t *testing.T) { }, }, Config: testAccAccountConfig_role0(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.CompareValuePairs( resourceName, tfjsonpath.New("cloudwatch_role_arn"), @@ -206,7 +227,21 @@ func testAccAccount_frameworkMigration_cloudwatchRoleARN(t *testing.T) { { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccAccountConfig_role0(rName), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.CompareValuePairs( + resourceName, tfjsonpath.New("cloudwatch_role_arn"), + "aws_iam_role.test[0]", tfjsonpath.New(names.AttrARN), + compare.ValuesSame(), + ), + }, }, }, }) diff --git a/internal/service/apigateway/base_path_mapping_test.go b/internal/service/apigateway/base_path_mapping_test.go index 1239a41cf03c..2f522625f94b 100644 --- a/internal/service/apigateway/base_path_mapping_test.go +++ b/internal/service/apigateway/base_path_mapping_test.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/apigateway" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -207,11 +208,23 @@ func TestAccAPIGatewayBasePathMapping_updateIDFormat(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckBasePathExists(ctx, resourceName, &conf), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccBasePathMappingConfig_basic(name, key, certificate, acctest.ResourcePrefix), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/apigateway/domain_name_test.go b/internal/service/apigateway/domain_name_test.go index 0a79661240f5..b149955e1279 100644 --- a/internal/service/apigateway/domain_name_test.go +++ b/internal/service/apigateway/domain_name_test.go @@ -16,8 +16,13 @@ import ( "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" "github.com/hashicorp/terraform-provider-aws/internal/acctest" + tfstatecheck "github.com/hashicorp/terraform-provider-aws/internal/acctest/statecheck" "github.com/hashicorp/terraform-provider-aws/internal/conns" tfapigateway "github.com/hashicorp/terraform-provider-aws/internal/service/apigateway" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" @@ -473,13 +478,33 @@ func TestAccAPIGatewayDomainName_updateIDFormat(t *testing.T) { Config: testAccDomainNameConfig_regionalCertificateARN(rName, key, certificate), Check: resource.ComposeTestCheckFunc( testAccCheckDomainNameExists(ctx, resourceName, &domainName), - resource.TestCheckNoResourceAttr(resourceName, "domain_name_id"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + tfstatecheck.ExpectNoValue(resourceName, tfjsonpath.New("domain_name_id")), + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccDomainNameConfig_regionalCertificateARN(rName, key, certificate), - PlanOnly: true, + Check: resource.ComposeTestCheckFunc( + testAccCheckDomainNameExists(ctx, resourceName, &domainName), + ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("domain_name_id"), knownvalue.NotNull()), + }, }, }, }) diff --git a/internal/service/apigateway/rest_api_test.go b/internal/service/apigateway/rest_api_test.go index cf532874e174..bb04ee7d9396 100644 --- a/internal/service/apigateway/rest_api_test.go +++ b/internal/service/apigateway/rest_api_test.go @@ -14,7 +14,11 @@ import ( "github.com/aws/aws-sdk-go-v2/service/apigateway/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs" @@ -1362,6 +1366,7 @@ func TestAccAPIGatewayRestAPI_Policy_basic(t *testing.T) { func TestAccAPIGatewayRestAPI_Policy_order(t *testing.T) { ctx := acctest.Context(t) + var conf apigateway.GetRestApiOutput resourceName := "aws_api_gateway_rest_api.test" expectedPolicyText := `{"Statement":[{"Action":"execute-api:Invoke","Condition":{"IpAddress":{"aws:SourceIp":["123.123.123.123/32","122.122.122.122/32","169.254.169.253/32"]}},"Effect":"Allow","Principal":{"AWS":"*"},"Resource":"*"}],"Version":"2012-10-17"}` rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -1375,12 +1380,30 @@ func TestAccAPIGatewayRestAPI_Policy_order(t *testing.T) { { Config: testAccRestAPIConfig_policyOrder(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(resourceName, names.AttrPolicy, expectedPolicyText), + testAccCheckRESTAPIExists(ctx, resourceName, &conf), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrPolicy), knownvalue.StringExact(expectedPolicyText)), + }, }, { - Config: testAccRestAPIConfig_policyNewOrder(rName), - PlanOnly: true, + Config: testAccRestAPIConfig_policyNewOrder(rName), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckRESTAPIExists(ctx, resourceName, &conf), + ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 9e6484eecc3d3e8547685e5ab0c95630d80bb25f Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 12:22:20 -0400 Subject: [PATCH 02/27] Fix 'testAccAccount_basic'. --- internal/service/apigateway/account_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/service/apigateway/account_test.go b/internal/service/apigateway/account_test.go index 223d5ec85cb2..d93960d25ea8 100644 --- a/internal/service/apigateway/account_test.go +++ b/internal/service/apigateway/account_test.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" "github.com/hashicorp/terraform-provider-aws/internal/acctest" + tfknownvalue "github.com/hashicorp/terraform-provider-aws/internal/acctest/knownvalue" "github.com/hashicorp/terraform-provider-aws/internal/conns" tfapigateway "github.com/hashicorp/terraform-provider-aws/internal/service/apigateway" "github.com/hashicorp/terraform-provider-aws/names" @@ -40,8 +41,8 @@ func testAccAccount_basic(t *testing.T) { ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("api_key_version"), knownvalue.NotNull()), statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("cloudwatch_role_arn"), knownvalue.StringExact("")), - statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("features"), knownvalue.NotNull()), - statecheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrID), knownvalue.StringExact("api-gateway-account")), + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("features"), knownvalue.Null()), + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrID), tfknownvalue.AccountID()), statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("throttle_settings"), knownvalue.ListExact([]knownvalue.Check{ knownvalue.ObjectExact(map[string]knownvalue.Check{ "burst_limit": knownvalue.Int32Exact(5000), From 914b591948d38f0b67ef4eeea13c5a5282973f18 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 13:32:27 -0400 Subject: [PATCH 03/27] r/aws_api_gateway_base_path_mapping: Fixup acceptance tests. --- .../apigateway/base_path_mapping_test.go | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/internal/service/apigateway/base_path_mapping_test.go b/internal/service/apigateway/base_path_mapping_test.go index 2f522625f94b..613c820b3599 100644 --- a/internal/service/apigateway/base_path_mapping_test.go +++ b/internal/service/apigateway/base_path_mapping_test.go @@ -372,9 +372,19 @@ resource "aws_api_gateway_integration" "test" { resource "aws_api_gateway_deployment" "test" { rest_api_id = aws_api_gateway_rest_api.test.id - stage_name = "test" + depends_on = [aws_api_gateway_integration.test] } + +resource "aws_api_gateway_stage" "test" { + rest_api_id = aws_api_gateway_rest_api.test.id + stage_name = "test" + deployment_id = aws_api_gateway_deployment.test.id + + lifecycle { + ignore_changes = [variables, canary_settings] + } +} `, domainName, acctest.TLSPEMEscapeNewlines(certificate), acctest.TLSPEMEscapeNewlines(key)) } @@ -383,7 +393,7 @@ func testAccBasePathMappingConfig_basic(domainName, key, certificate, basePath s resource "aws_api_gateway_base_path_mapping" "test" { api_id = aws_api_gateway_rest_api.test.id base_path = %[1]q - stage_name = aws_api_gateway_deployment.test.stage_name + stage_name = aws_api_gateway_stage.test.stage_name domain_name = aws_api_gateway_domain_name.test.domain_name } `, basePath)) @@ -453,14 +463,24 @@ resource "aws_api_gateway_integration" "test" { resource "aws_api_gateway_deployment" "test" { rest_api_id = aws_api_gateway_rest_api.test.id - stage_name = "test" + depends_on = [aws_api_gateway_integration.test] } +resource "aws_api_gateway_stage" "test" { + rest_api_id = aws_api_gateway_rest_api.test.id + stage_name = "test" + deployment_id = aws_api_gateway_deployment.test.id + + lifecycle { + ignore_changes = [variables, canary_settings] + } +} + resource "aws_api_gateway_base_path_mapping" "test" { api_id = aws_api_gateway_rest_api.test.id base_path = %[4]q - stage_name = aws_api_gateway_deployment.test.stage_name + stage_name = aws_api_gateway_stage.test.stage_name domain_name = aws_api_gateway_domain_name.test.domain_name domain_name_id = aws_api_gateway_domain_name.test.domain_name_id } @@ -478,9 +498,7 @@ resource "aws_api_gateway_rest_api" "test2" { } } - resource "aws_api_gateway_stage" "test2" { - depends_on = [ aws_api_gateway_deployment.test ] @@ -510,10 +528,9 @@ resource "aws_api_gateway_integration" "test2" { type = "MOCK" } - resource "aws_api_gateway_deployment" "test2" { rest_api_id = aws_api_gateway_rest_api.test2.id - stage_name = "test" + depends_on = [aws_api_gateway_integration.test2] } From a807357350c17d1b60cc1bddc37ddaaed1912d50 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 14:23:04 -0400 Subject: [PATCH 04/27] Fix terrafmt errors. --- internal/service/apigateway/base_path_mapping_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/apigateway/base_path_mapping_test.go b/internal/service/apigateway/base_path_mapping_test.go index 613c820b3599..241111943f81 100644 --- a/internal/service/apigateway/base_path_mapping_test.go +++ b/internal/service/apigateway/base_path_mapping_test.go @@ -373,7 +373,7 @@ resource "aws_api_gateway_integration" "test" { resource "aws_api_gateway_deployment" "test" { rest_api_id = aws_api_gateway_rest_api.test.id - depends_on = [aws_api_gateway_integration.test] + depends_on = [aws_api_gateway_integration.test] } resource "aws_api_gateway_stage" "test" { @@ -464,7 +464,7 @@ resource "aws_api_gateway_integration" "test" { resource "aws_api_gateway_deployment" "test" { rest_api_id = aws_api_gateway_rest_api.test.id - depends_on = [aws_api_gateway_integration.test] + depends_on = [aws_api_gateway_integration.test] } resource "aws_api_gateway_stage" "test" { @@ -531,7 +531,7 @@ resource "aws_api_gateway_integration" "test2" { resource "aws_api_gateway_deployment" "test2" { rest_api_id = aws_api_gateway_rest_api.test2.id - depends_on = [aws_api_gateway_integration.test2] + depends_on = [aws_api_gateway_integration.test2] } resource "aws_api_gateway_base_path_mapping" "test" { From 2a4d17e318bad480bd1fce7c12f735a15d48ac72 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 14:26:10 -0400 Subject: [PATCH 05/27] appconfig: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- .../service/appconfig/environment_test.go | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/internal/service/appconfig/environment_test.go b/internal/service/appconfig/environment_test.go index 71b606d69039..fd60abf6d443 100644 --- a/internal/service/appconfig/environment_test.go +++ b/internal/service/appconfig/environment_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -281,11 +282,26 @@ func TestAccAppConfigEnvironment_frameworkMigration_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckEnvironmentExists(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccEnvironmentConfig_description(rName, description), - PlanOnly: true, + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckEnvironmentExists(ctx, resourceName), + ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -312,11 +328,26 @@ func TestAccAppConfigEnvironment_frameworkMigration_monitors(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckEnvironmentExists(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccEnvironmentConfig_monitors(rName, 2), - PlanOnly: true, + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckEnvironmentExists(ctx, resourceName), + ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 8a795dca612f5bc8a85adada2ea0152efb599218 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 14:32:16 -0400 Subject: [PATCH 06/27] Remove unneccessary PlanOnly test cases. --- internal/service/appflow/flow_test.go | 8 -------- internal/service/appmesh/mesh_test.go | 4 ---- 2 files changed, 12 deletions(-) diff --git a/internal/service/appflow/flow_test.go b/internal/service/appflow/flow_test.go index 8a173e7bc8e4..8476ad7610bf 100644 --- a/internal/service/appflow/flow_test.go +++ b/internal/service/appflow/flow_test.go @@ -274,10 +274,6 @@ func TestAccAppFlowFlow_task_mapAll(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "task.#", "1"), ), }, - { - Config: testAccFlowConfig_task_mapAll(rName), - PlanOnly: true, - }, }, }) } @@ -329,10 +325,6 @@ func TestAccAppFlowFlow_metadataCatalog(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "destination_flow_config.0.destination_connector_properties.0.s3.0.s3_output_format_config.0.prefix_config.0.prefix_hierarchy.#", "2"), ), }, - { - Config: testAccFlowConfig_metadata_catalog(rName), - PlanOnly: true, - }, }, }) } diff --git a/internal/service/appmesh/mesh_test.go b/internal/service/appmesh/mesh_test.go index 63a0eea1cff4..2f9184b4f615 100644 --- a/internal/service/appmesh/mesh_test.go +++ b/internal/service/appmesh/mesh_test.go @@ -113,10 +113,6 @@ func testAccMesh_egressFilter(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "spec.0.egress_filter.0.type", "DROP_ALL"), ), }, - { - PlanOnly: true, - Config: testAccMeshConfig_basic(rName), - }, }, }) } From 9f4d1c21af426d81c13cfdaf63bf52069bc0684c Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 14:32:34 -0400 Subject: [PATCH 07/27] appstream: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/appstream/stack_test.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/service/appstream/stack_test.go b/internal/service/appstream/stack_test.go index a296d959ad45..061eb667c58d 100644 --- a/internal/service/appstream/stack_test.go +++ b/internal/service/appstream/stack_test.go @@ -11,6 +11,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/appstream/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -263,10 +264,22 @@ func TestAccAppStreamStack_applicationSettings_removeFromDisabled(t *testing.T) resource.TestCheckResourceAttr(resourceName, "application_settings.0.enabled", acctest.CtFalse), resource.TestCheckResourceAttr(resourceName, "application_settings.0.settings_group", ""), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccStackConfig_applicationSettingsRemoved(rName), - PlanOnly: true, + Config: testAccStackConfig_applicationSettingsRemoved(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 644be0af679290c89061befecfe7d366ecb4d620 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 14:36:45 -0400 Subject: [PATCH 08/27] backup: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/backup/vault_policy.go | 14 ++------------ internal/service/backup/vault_policy_test.go | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/internal/service/backup/vault_policy.go b/internal/service/backup/vault_policy.go index bedcdb58c9eb..0b026154cd27 100644 --- a/internal/service/backup/vault_policy.go +++ b/internal/service/backup/vault_policy.go @@ -15,10 +15,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" @@ -46,17 +46,7 @@ func resourceVaultPolicy() *schema.Resource { Required: true, ForceNew: true, }, - names.AttrPolicy: { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsJSON, - DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs, - DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, - }, + names.AttrPolicy: sdkv2.IAMPolicyDocumentSchemaRequired(), }, } } diff --git a/internal/service/backup/vault_policy_test.go b/internal/service/backup/vault_policy_test.go index 2d99b37f06c1..bcf52ec9c355 100644 --- a/internal/service/backup/vault_policy_test.go +++ b/internal/service/backup/vault_policy_test.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/backup" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -142,11 +143,24 @@ func TestAccBackupVaultPolicy_ignoreEquivalent(t *testing.T) { Config: testAccVaultPolicyConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckVaultPolicyExists(ctx, resourceName, &vault), - resource.TestMatchResourceAttr(resourceName, names.AttrPolicy, regexache.MustCompile("\"Version\":\"2012-10-17\""))), + resource.TestMatchResourceAttr(resourceName, names.AttrPolicy, regexache.MustCompile("\"Version\":\"2012-10-17\"")), + ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccVaultPolicyConfig_newOrder(rName), - PlanOnly: true, + Config: testAccVaultPolicyConfig_newOrder(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From ef5516152fcd3de4525b81d3e285275257361f2b Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 14:45:34 -0400 Subject: [PATCH 09/27] cloudformation: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/cloudformation/stack_test.go | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/internal/service/cloudformation/stack_test.go b/internal/service/cloudformation/stack_test.go index 826f551488b0..4ffd05bed99f 100644 --- a/internal/service/cloudformation/stack_test.go +++ b/internal/service/cloudformation/stack_test.go @@ -46,6 +46,11 @@ func TestAccCloudFormationStack_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "parameters.%", "0"), resource.TestCheckNoResourceAttr(resourceName, "template_url"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -53,8 +58,15 @@ func TestAccCloudFormationStack_basic(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccStackConfig_basic(rName), - PlanOnly: true, + Config: testAccStackConfig_basic(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -441,13 +453,6 @@ func TestAccCloudFormationStack_withTransform(t *testing.T) { testAccCheckStackExists(ctx, resourceName, &stack), ), }, - { - PlanOnly: true, - Config: testAccStackConfig_transform(rName), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckStackExists(ctx, resourceName, &stack), - ), - }, }, }) } From d556b62df79e09ffa60edd468317e50c06186550 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 14:52:16 -0400 Subject: [PATCH 10/27] codeartifact: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- .../codeartifact/domain_permissions_policy.go | 14 ++-------- .../domain_permissions_policy_test.go | 17 +++++++++-- internal/service/codeartifact/domain_test.go | 28 +++++++++++++++++-- .../repository_permissions_policy.go | 14 ++-------- .../repository_permissions_policy_test.go | 17 +++++++++-- 5 files changed, 59 insertions(+), 31 deletions(-) diff --git a/internal/service/codeartifact/domain_permissions_policy.go b/internal/service/codeartifact/domain_permissions_policy.go index 8206b06853e9..603dc1d1f6bb 100644 --- a/internal/service/codeartifact/domain_permissions_policy.go +++ b/internal/service/codeartifact/domain_permissions_policy.go @@ -14,10 +14,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" @@ -45,17 +45,7 @@ func resourceDomainPermissionsPolicy() *schema.Resource { Computed: true, ForceNew: true, }, - "policy_document": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsJSON, - DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs, - DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, - }, + "policy_document": sdkv2.IAMPolicyDocumentSchemaOptionalComputed(), "policy_revision": { Type: schema.TypeString, Optional: true, diff --git a/internal/service/codeartifact/domain_permissions_policy_test.go b/internal/service/codeartifact/domain_permissions_policy_test.go index 35f7adee4aff..9ecb7c2bf8c2 100644 --- a/internal/service/codeartifact/domain_permissions_policy_test.go +++ b/internal/service/codeartifact/domain_permissions_policy_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -81,10 +82,22 @@ func testAccDomainPermissionsPolicy_ignoreEquivalent(t *testing.T) { resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:ListRepositoriesInDomain")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", names.AttrOwner), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccDomainPermissionsPolicyConfig_newOrder(rName), - PlanOnly: true, + Config: testAccDomainPermissionsPolicyConfig_newOrder(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/codeartifact/domain_test.go b/internal/service/codeartifact/domain_test.go index 14a8fd21d257..2f45226bfeff 100644 --- a/internal/service/codeartifact/domain_test.go +++ b/internal/service/codeartifact/domain_test.go @@ -11,7 +11,11 @@ import ( "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" tfcodeartifact "github.com/hashicorp/terraform-provider-aws/internal/service/codeartifact" @@ -175,14 +179,32 @@ func testAccDomain_MigrateAssetSizeBytesToString(t *testing.T) { Config: testAccDomainConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), - resource.TestCheckResourceAttr(resourceName, "asset_size_bytes", "0"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("asset_size_bytes"), knownvalue.Int64Exact(0)), + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrDomain), knownvalue.StringExact(rName)), + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccDomainConfig_basic(rName), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("asset_size_bytes"), knownvalue.StringExact("0")), + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New(names.AttrDomain), knownvalue.StringExact(rName)), + }, }, }, }) diff --git a/internal/service/codeartifact/repository_permissions_policy.go b/internal/service/codeartifact/repository_permissions_policy.go index 1dacef38dc48..fd90780bfe7e 100644 --- a/internal/service/codeartifact/repository_permissions_policy.go +++ b/internal/service/codeartifact/repository_permissions_policy.go @@ -14,10 +14,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" @@ -45,17 +45,7 @@ func resourceRepositoryPermissionsPolicy() *schema.Resource { Computed: true, ForceNew: true, }, - "policy_document": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsJSON, - DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs, - DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, - }, + "policy_document": sdkv2.IAMPolicyDocumentSchemaRequired(), "policy_revision": { Type: schema.TypeString, Optional: true, diff --git a/internal/service/codeartifact/repository_permissions_policy_test.go b/internal/service/codeartifact/repository_permissions_policy_test.go index f70f768a5f0d..69fd4555d8b4 100644 --- a/internal/service/codeartifact/repository_permissions_policy_test.go +++ b/internal/service/codeartifact/repository_permissions_policy_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -80,10 +81,22 @@ func testAccRepositoryPermissionsPolicy_ignoreEquivalent(t *testing.T) { resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", names.AttrOwner), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccRepositoryPermissionsPolicyConfig_newOrder(rName), - PlanOnly: true, + Config: testAccRepositoryPermissionsPolicyConfig_newOrder(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 07d5b5ea39829faf003208fc12f976851fb4aa33 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 15:01:15 -0400 Subject: [PATCH 11/27] Remove unneccessary PlanOnly test cases. --- .../media_insights_pipeline_configuration_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration_test.go b/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration_test.go index 590fac5f5939..7afb6c24abf2 100644 --- a/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration_test.go +++ b/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration_test.go @@ -55,11 +55,6 @@ func TestAccChimeSDKMediaPipelinesMediaInsightsPipelineConfiguration_basic(t *te acctest.CheckResourceAttrRegionalARN(ctx, resourceName, names.AttrARN, "chime", fmt.Sprintf(`media-insights-pipeline-configuration/%s`, rName)), ), }, - { - Config: testAccMediaInsightsPipelineConfigurationConfig_basic(rName, roleName, streamName), - PlanOnly: true, - ExpectNonEmptyPlan: false, - }, { ResourceName: resourceName, ImportState: true, From 1b8a667b9f250095693901a90e4771cace196595 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 15:05:37 -0400 Subject: [PATCH 12/27] cognitoidp: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- .../managed_user_pool_client_test.go | 18 +++-- .../cognitoidp/user_pool_client_test.go | 72 ++++++++++++++----- internal/service/cognitoidp/user_test.go | 15 +++- 3 files changed, 84 insertions(+), 21 deletions(-) diff --git a/internal/service/cognitoidp/managed_user_pool_client_test.go b/internal/service/cognitoidp/managed_user_pool_client_test.go index b0abd861014f..9b0e2ac40c65 100644 --- a/internal/service/cognitoidp/managed_user_pool_client_test.go +++ b/internal/service/cognitoidp/managed_user_pool_client_test.go @@ -1038,6 +1038,11 @@ func TestAccCognitoIDPManagedUserPoolClient_emptySets(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolClientExists(ctx, resourceName, &client), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("allowed_oauth_flows"), knownvalue.SetExact([]knownvalue.Check{ knownvalue.StringExact("code"), @@ -1068,8 +1073,15 @@ func TestAccCognitoIDPManagedUserPoolClient_emptySets(t *testing.T) { }, }, { - Config: testAccManagedUserPoolClientConfig_nulls(rName), - PlanOnly: true, + Config: testAccManagedUserPoolClientConfig_nulls(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1127,8 +1139,6 @@ func TestAccCognitoIDPManagedUserPoolClient_nulls(t *testing.T) { }, { Config: testAccManagedUserPoolClientConfig_emptySets(rName), - // This currently shows a diff of "null -> []" - // PlanOnly: true, Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolClientExists(ctx, resourceName, &client), ), diff --git a/internal/service/cognitoidp/user_pool_client_test.go b/internal/service/cognitoidp/user_pool_client_test.go index dbfd8a945627..635908824a9a 100644 --- a/internal/service/cognitoidp/user_pool_client_test.go +++ b/internal/service/cognitoidp/user_pool_client_test.go @@ -996,6 +996,11 @@ func TestAccCognitoIDPUserPoolClient_emptySets(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolClientExists(ctx, resourceName, &client), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("allowed_oauth_flows"), knownvalue.SetExact([]knownvalue.Check{})), statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("allowed_oauth_scopes"), knownvalue.SetExact([]knownvalue.Check{})), @@ -1014,8 +1019,15 @@ func TestAccCognitoIDPUserPoolClient_emptySets(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccUserPoolClientConfig_nulls(rName), - PlanOnly: true, + Config: testAccUserPoolClientConfig_nulls(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1038,6 +1050,11 @@ func TestAccCognitoIDPUserPoolClient_nulls(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolClientExists(ctx, resourceName, &client), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("allowed_oauth_flows"), knownvalue.SetExact([]knownvalue.Check{})), statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("allowed_oauth_scopes"), knownvalue.SetExact([]knownvalue.Check{})), @@ -1056,8 +1073,15 @@ func TestAccCognitoIDPUserPoolClient_nulls(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccUserPoolClientConfig_emptySets(rName), - PlanOnly: true, + Config: testAccUserPoolClientConfig_emptySets(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1085,6 +1109,11 @@ func TestAccCognitoIDPUserPoolClient_frameworkMigration_nulls(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolClientExists(ctx, resourceName, &client), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("allowed_oauth_flows"), knownvalue.Null()), statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("allowed_oauth_scopes"), knownvalue.Null()), @@ -1103,8 +1132,15 @@ func TestAccCognitoIDPUserPoolClient_frameworkMigration_nulls(t *testing.T) { VersionConstraint: "4.62.0", }, }, - Config: testAccUserPoolClientConfig_nulls(rName), - PlanOnly: true, + Config: testAccUserPoolClientConfig_nulls(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1132,6 +1168,11 @@ func TestAccCognitoIDPUserPoolClient_frameworkMigration_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolClientExists(ctx, resourceName, &client), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ExternalProviders: map[string]resource.ExternalProvider{ @@ -1140,8 +1181,15 @@ func TestAccCognitoIDPUserPoolClient_frameworkMigration_basic(t *testing.T) { VersionConstraint: "4.62.0", }, }, - Config: testAccUserPoolClientConfig_basic(rName), - PlanOnly: true, + Config: testAccUserPoolClientConfig_basic(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1180,14 +1228,6 @@ func TestAccCognitoIDPUserPoolClient_frameworkMigration_emptySet(t *testing.T) { statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("write_attributes"), knownvalue.Null()), }, }, - /* - TODO Investigate... - { - ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, - Config: testAccUserPoolClientConfig_emptySets(rName), - PlanOnly: true, - }, - */ }, }) } diff --git a/internal/service/cognitoidp/user_test.go b/internal/service/cognitoidp/user_test.go index ad103ec2d7b0..62796a48f341 100644 --- a/internal/service/cognitoidp/user_test.go +++ b/internal/service/cognitoidp/user_test.go @@ -14,6 +14,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -325,11 +326,23 @@ func TestAccCognitoIDPUser_v5560Regression(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, string(awstypes.UserStatusTypeForceChangePassword)), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccUserConfig_v5560Regression(rUserPoolName, rUserName), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From f62780ccbabfb7f3148e2ae22f03e0807508dfa1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 23 Jun 2025 15:52:17 -0400 Subject: [PATCH 13/27] comprehend: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- .../comprehend/document_classifier_test.go | 145 +++++++++++++++--- .../comprehend/entity_recognizer_test.go | 33 +++- 2 files changed, 156 insertions(+), 22 deletions(-) diff --git a/internal/service/comprehend/document_classifier_test.go b/internal/service/comprehend/document_classifier_test.go index 901bb4a961eb..a700a0cc14f7 100644 --- a/internal/service/comprehend/document_classifier_test.go +++ b/internal/service/comprehend/document_classifier_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -67,6 +68,11 @@ func TestAccComprehendDocumentClassifier_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "volume_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, "vpc_config.#", "0"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -74,8 +80,15 @@ func TestAccComprehendDocumentClassifier_basic(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_Mode_singleLabel(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_Mode_singleLabel(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -423,6 +436,11 @@ func TestAccComprehendDocumentClassifier_multiLabel_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "volume_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, "vpc_config.#", "0"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -430,8 +448,15 @@ func TestAccComprehendDocumentClassifier_multiLabel_basic(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_multiLabel_defaultDelimiter(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_multiLabel_defaultDelimiter(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -466,6 +491,11 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_basic(t *testing.T) { resource.TestMatchResourceAttr(resourceName, "output_data_config.0.s3_uri", regexache.MustCompile(`s3://.+/outputs`)), resource.TestMatchResourceAttr(resourceName, "output_data_config.0.output_s3_uri", regexache.MustCompile(`s3://.+/outputs/[0-9A-Za-z-]+/output/output.tar.gz`)), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -473,8 +503,15 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_basic(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_outputDataConfig_basic(rName, "outputs/"), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_outputDataConfig_basic(rName, "outputs/"), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -508,6 +545,11 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateID(t *test resource.TestCheckResourceAttr(resourceName, "output_data_config.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "output_data_config.0.kms_key_id", "aws_kms_key.output", names.AttrKeyID), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -515,8 +557,15 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateID(t *test ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyARN(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyARN(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -550,6 +599,11 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateARN(t *tes resource.TestCheckResourceAttr(resourceName, "output_data_config.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "output_data_config.0.kms_key_id", "aws_kms_key.output", names.AttrARN), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -557,8 +611,15 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateARN(t *tes ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyId(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyId(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -592,6 +653,11 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateAliasName( resource.TestCheckResourceAttr(resourceName, "output_data_config.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "output_data_config.0.kms_key_id", "aws_kms_alias.output", names.AttrName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -599,8 +665,15 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateAliasName( ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyAliasARN(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyAliasARN(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -634,6 +707,11 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateAliasARN(t resource.TestCheckResourceAttr(resourceName, "output_data_config.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "output_data_config.0.kms_key_id", "aws_kms_alias.output", names.AttrARN), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -641,8 +719,15 @@ func TestAccComprehendDocumentClassifier_outputDataConfig_kmsKeyCreateAliasARN(t ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyAliasName(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_outputDataConfig_kmsKeyAliasName(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -885,6 +970,11 @@ func TestAccComprehendDocumentClassifier_KMSKeys_CreateIDs(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "model_kms_key_id", "aws_kms_key.model", names.AttrKeyID), resource.TestCheckResourceAttrPair(resourceName, "volume_kms_key_id", "aws_kms_key.volume", names.AttrKeyID), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -892,8 +982,15 @@ func TestAccComprehendDocumentClassifier_KMSKeys_CreateIDs(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_kmsKeyARNs(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_kmsKeyARNs(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -927,6 +1024,11 @@ func TestAccComprehendDocumentClassifier_KMSKeys_CreateARNs(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "model_kms_key_id", "aws_kms_key.model", names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "volume_kms_key_id", "aws_kms_key.volume", names.AttrARN), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -934,8 +1036,15 @@ func TestAccComprehendDocumentClassifier_KMSKeys_CreateARNs(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccDocumentClassifierConfig_kmsKeyIds(rName), - PlanOnly: true, + Config: testAccDocumentClassifierConfig_kmsKeyIds(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/comprehend/entity_recognizer_test.go b/internal/service/comprehend/entity_recognizer_test.go index 7fe2f306da40..f6591c1aab86 100644 --- a/internal/service/comprehend/entity_recognizer_test.go +++ b/internal/service/comprehend/entity_recognizer_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -536,6 +537,11 @@ func TestAccComprehendEntityRecognizer_KMSKeys_CreateIDs(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "model_kms_key_id", "aws_kms_key.model", names.AttrKeyID), resource.TestCheckResourceAttrPair(resourceName, "volume_kms_key_id", "aws_kms_key.volume", names.AttrKeyID), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -543,8 +549,15 @@ func TestAccComprehendEntityRecognizer_KMSKeys_CreateIDs(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccEntityRecognizerConfig_kmsKeyARNs(rName), - PlanOnly: true, + Config: testAccEntityRecognizerConfig_kmsKeyARNs(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -578,6 +591,11 @@ func TestAccComprehendEntityRecognizer_KMSKeys_CreateARNs(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "model_kms_key_id", "aws_kms_key.model", names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "volume_kms_key_id", "aws_kms_key.volume", names.AttrARN), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -585,8 +603,15 @@ func TestAccComprehendEntityRecognizer_KMSKeys_CreateARNs(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccEntityRecognizerConfig_kmsKeyIds(rName), - PlanOnly: true, + Config: testAccEntityRecognizerConfig_kmsKeyIds(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 4720bb9f0ace57f5ae1d9b87990a5fdc0d65f11a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 10:09:56 -0400 Subject: [PATCH 14/27] dax: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/dax/cluster_test.go | 63 ++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/internal/service/dax/cluster_test.go b/internal/service/dax/cluster_test.go index 3a2b120f9224..5fc425d33049 100644 --- a/internal/service/dax/cluster_test.go +++ b/internal/service/dax/cluster_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -145,6 +146,11 @@ func TestAccDAXCluster_Encryption_disabled(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "server_side_encryption.#", "1"), resource.TestCheckResourceAttr(resourceName, "server_side_encryption.0.enabled", acctest.CtFalse), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -153,9 +159,15 @@ func TestAccDAXCluster_Encryption_disabled(t *testing.T) { }, // Ensure it shows no difference when removing server_side_encryption configuration { - Config: testAccClusterConfig_basic(rString), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccClusterConfig_basic(rString), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -180,6 +192,11 @@ func TestAccDAXCluster_Encryption_enabled(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "server_side_encryption.#", "1"), resource.TestCheckResourceAttr(resourceName, "server_side_encryption.0.enabled", acctest.CtTrue), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -188,9 +205,12 @@ func TestAccDAXCluster_Encryption_enabled(t *testing.T) { }, // Ensure it shows a difference when removing server_side_encryption configuration { - Config: testAccClusterConfig_basic(rString), - PlanOnly: true, - ExpectNonEmptyPlan: true, + Config: testAccClusterConfig_basic(rString), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace), + }, + }, }, }, }) @@ -215,6 +235,11 @@ func TestAccDAXCluster_EndpointEncryption_disabled(t *testing.T) { testAccCheckClusterExists(ctx, resourceName, &dc), resource.TestCheckResourceAttr(resourceName, "cluster_endpoint_encryption_type", clusterEndpointEncryptionType), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -223,9 +248,15 @@ func TestAccDAXCluster_EndpointEncryption_disabled(t *testing.T) { }, // Ensure it shows no difference when removing cluster_endpoint_encryption_type configuration { - Config: testAccClusterConfig_basic(rString), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccClusterConfig_basic(rString), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -254,6 +285,11 @@ func TestAccDAXCluster_EndpointEncryption_enabled(t *testing.T) { testAccCheckClusterExists(ctx, resourceName, &dc), resource.TestCheckResourceAttr(resourceName, "cluster_endpoint_encryption_type", clusterEndpointEncryptionType), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -262,9 +298,12 @@ func TestAccDAXCluster_EndpointEncryption_enabled(t *testing.T) { }, // Ensure it shows a difference when removing cluster_endpoint_encryption_type configuration { - Config: testAccClusterConfig_basic(rString), - PlanOnly: true, - ExpectNonEmptyPlan: true, + Config: testAccClusterConfig_basic(rString), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace), + }, + }, }, }, }) From 1b8ad469dab33d8a4c1de78e6d8ad5cea48012c9 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 11:08:30 -0400 Subject: [PATCH 15/27] dms: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/dms/replication_task_test.go | 10 +++++----- internal/service/dms/s3_endpoint_test.go | 8 -------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/internal/service/dms/replication_task_test.go b/internal/service/dms/replication_task_test.go index 9b16db3d49dd..93352e9c5a9f 100644 --- a/internal/service/dms/replication_task_test.go +++ b/internal/service/dms/replication_task_test.go @@ -508,11 +508,11 @@ func TestAccDMSReplicationTask_s3ToRDS(t *testing.T) { testAccCheckReplicationTaskExists(ctx, resourceName, &v), resource.TestCheckResourceAttrSet(resourceName, "replication_task_arn"), ), - }, - { - Config: testAccReplicationTaskConfig_s3ToRDS(rName), - PlanOnly: true, - ExpectNonEmptyPlan: false, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, }, }) diff --git a/internal/service/dms/s3_endpoint_test.go b/internal/service/dms/s3_endpoint_test.go index a02050f254b0..4e1419a2c22f 100644 --- a/internal/service/dms/s3_endpoint_test.go +++ b/internal/service/dms/s3_endpoint_test.go @@ -243,10 +243,6 @@ func TestAccDMSS3Endpoint_simple(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "use_task_start_time_for_full_load_timestamp", acctest.CtFalse), ), }, - { - Config: testAccS3EndpointConfig_simple(rName), - PlanOnly: true, - }, }, }) } @@ -299,10 +295,6 @@ func TestAccDMSS3Endpoint_sourceSimple(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "use_task_start_time_for_full_load_timestamp", acctest.CtFalse), ), }, - { - Config: testAccS3EndpointConfig_sourceSimple(rName), - PlanOnly: true, - }, { ResourceName: resourceName, ImportState: true, From 26e8cc3ce03c0605ebb0f45de484e9959d638edb Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 12:06:50 -0400 Subject: [PATCH 16/27] ds: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/ds/trust_test.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/internal/service/ds/trust_test.go b/internal/service/ds/trust_test.go index 06efc51b45e6..dbd5bf8e43a8 100644 --- a/internal/service/ds/trust_test.go +++ b/internal/service/ds/trust_test.go @@ -12,8 +12,12 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/directoryservice/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" "github.com/hashicorp/terraform-provider-aws/internal/acctest" + tfknownvalue "github.com/hashicorp/terraform-provider-aws/internal/acctest/knownvalue" "github.com/hashicorp/terraform-provider-aws/internal/conns" tfds "github.com/hashicorp/terraform-provider-aws/internal/service/ds" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" @@ -400,12 +404,26 @@ func TestAccDSTrust_TrustTypeSpecifyDefault(t *testing.T) { Config: testAccTrustConfig_basic(rName, domainName, domainNameOther), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckTrustExists(ctx, resourceName, &v), - resource.TestCheckResourceAttr(resourceName, "trust_type", string(awstypes.TrustTypeForest)), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("trust_type"), tfknownvalue.StringExact(awstypes.TrustTypeForest)), + }, }, { - Config: testAccTrustConfig_TrustType(rName, domainName, domainNameOther, awstypes.TrustTypeForest), - PlanOnly: true, + Config: testAccTrustConfig_TrustType(rName, domainName, domainNameOther, awstypes.TrustTypeForest), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 2b2f2c4e93789462db570ee8dea3256c797a6781 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 14:26:48 -0400 Subject: [PATCH 17/27] dynamodb: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/dynamodb/table_test.go | 112 ++++++++++++++++++++---- 1 file changed, 97 insertions(+), 15 deletions(-) diff --git a/internal/service/dynamodb/table_test.go b/internal/service/dynamodb/table_test.go index 05f017427978..058cedc76f5e 100644 --- a/internal/service/dynamodb/table_test.go +++ b/internal/service/dynamodb/table_test.go @@ -22,6 +22,7 @@ import ( sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/knownvalue" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/statecheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-plugin-testing/tfjsonpath" @@ -1523,6 +1524,11 @@ func TestAccDynamoDBTable_GsiUpdateNonKeyAttributes_emptyPlan(t *testing.T) { resource.TestCheckTypeSetElemAttr(resourceName, "global_secondary_index.*.non_key_attributes.*", "AnotherAttribute"), resource.TestCheckTypeSetElemAttr(resourceName, "global_secondary_index.*.non_key_attributes.*", "RandomAttribute"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -1530,9 +1536,15 @@ func TestAccDynamoDBTable_GsiUpdateNonKeyAttributes_emptyPlan(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccTableConfig_gsiMultipleNonKeyAttributes(rName, reorderedAttributes), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccTableConfig_gsiMultipleNonKeyAttributes(rName, reorderedAttributes), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1557,6 +1569,11 @@ func TestAccDynamoDBTable_TTL_enabled(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckInitialTableExists(ctx, resourceName, &table), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("ttl"), knownvalue.ListExact([]knownvalue.Check{ knownvalue.ObjectExact(map[string]knownvalue.Check{ @@ -1572,9 +1589,15 @@ func TestAccDynamoDBTable_TTL_enabled(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccTableConfig_timeToLive_unset(rName), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccTableConfig_timeToLive_unset(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1599,6 +1622,11 @@ func TestAccDynamoDBTable_TTL_disabled(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckInitialTableExists(ctx, resourceName, &table), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("ttl"), knownvalue.ListExact([]knownvalue.Check{ knownvalue.ObjectExact(map[string]knownvalue.Check{ @@ -1614,9 +1642,15 @@ func TestAccDynamoDBTable_TTL_disabled(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccTableConfig_timeToLive_unset(rName), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccTableConfig_timeToLive_unset(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -2101,6 +2135,11 @@ func TestAccDynamoDBTable_Replica_single(t *testing.T) { acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "dynamodb", "table/{name}"), testAccCheckReplicaTags(ctx, resourceName, acctest.AlternateRegion(), map[string]string{}), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("replica"), knownvalue.SetExact([]knownvalue.Check{ knownvalue.ObjectExact(map[string]knownvalue.Check{ @@ -2127,6 +2166,11 @@ func TestAccDynamoDBTable_Replica_single(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckInitialTableExists(ctx, resourceName, &conf), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("replica"), knownvalue.SetExact([]knownvalue.Check{})), }, @@ -2136,6 +2180,11 @@ func TestAccDynamoDBTable_Replica_single(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckInitialTableExists(ctx, resourceName, &conf), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, ConfigStateChecks: []statecheck.StateCheck{ statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("replica"), knownvalue.SetExact([]knownvalue.Check{ knownvalue.ObjectExact(map[string]knownvalue.Check{ @@ -2152,8 +2201,15 @@ func TestAccDynamoDBTable_Replica_single(t *testing.T) { }, }, { - Config: testAccTableConfig_replica1(rName), - PlanOnly: true, + Config: testAccTableConfig_replica1(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -3192,6 +3248,11 @@ func TestAccDynamoDBTable_tableClassExplicitDefault(t *testing.T) { testAccCheckInitialTableExists(ctx, resourceName, &table), resource.TestCheckResourceAttr(resourceName, "table_class", "STANDARD"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -3199,8 +3260,15 @@ func TestAccDynamoDBTable_tableClassExplicitDefault(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccTableConfig_class(rName, "STANDARD"), - PlanOnly: true, + Config: testAccTableConfig_class(rName, "STANDARD"), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -3271,13 +3339,27 @@ func TestAccDynamoDBTable_tableClass_migrate(t *testing.T) { Config: testAccTableConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckInitialTableExists(ctx, resourceName, &table), - resource.TestCheckResourceAttr(resourceName, "table_class", ""), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, + ConfigStateChecks: []statecheck.StateCheck{ + statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("table_class"), knownvalue.StringExact("")), + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccTableConfig_basic(rName), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 9824660e7e0be9bdc41eede978f68f48c174e742 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 15:20:34 -0400 Subject: [PATCH 18/27] ec2: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/ec2/ec2_instance_test.go | 90 ++++++++++++++++--- .../ec2/vpc_default_security_group_test.go | 4 - .../ec2/vpc_default_vpc_dhcp_options_test.go | 15 +++- .../service/ec2/vpc_network_acl_rule_test.go | 33 ++++++- internal/service/ec2/vpc_route_table_test.go | 17 +++- internal/service/ec2/vpc_route_test.go | 17 +++- .../vpc_security_group_ingress_rule_test.go | 47 +++++++++- .../service/ec2/vpc_security_group_test.go | 44 +++++++-- internal/service/ec2/vpc_subnet_test.go | 51 +++++++++-- internal/service/ec2/vpc_test.go | 50 +++++++++-- 10 files changed, 322 insertions(+), 46 deletions(-) diff --git a/internal/service/ec2/ec2_instance_test.go b/internal/service/ec2/ec2_instance_test.go index 07ee9f605055..f2500dd8cbc4 100644 --- a/internal/service/ec2/ec2_instance_test.go +++ b/internal/service/ec2/ec2_instance_test.go @@ -1835,10 +1835,22 @@ func TestAccEC2Instance_BlockDeviceTags_defaultTagsRBDOverlap(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "ebs_block_device.0.tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "ebs_block_device.0.tags_all.%", "4"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { // 4 defaultTags + 4 rbdTags with 2 in common - Config: testAccInstanceConfig_blockDeviceTagsDefaultVolumeRBDEBS(defTags, emptyMap, rbdTags, emptyMap), - PlanOnly: true, + Config: testAccInstanceConfig_blockDeviceTagsDefaultVolumeRBDEBS(defTags, emptyMap, rbdTags, emptyMap), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1907,6 +1919,11 @@ func TestAccEC2Instance_BlockDeviceTags_defaultTagsVolumeTagsOverlap(t *testing. resource.TestCheckResourceAttr(resourceName, "volume_tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "volume_tags.every", "gnomesie"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { // 2 defaultTags + 1 volumeTags (overlap) Config: testAccInstanceConfig_blockDeviceTagsDefaultVolumeRBDEBS(defTags, volTags2, emptyMap, emptyMap), @@ -1917,6 +1934,11 @@ func TestAccEC2Instance_BlockDeviceTags_defaultTagsVolumeTagsOverlap(t *testing. resource.TestCheckResourceAttr(resourceName, "volume_tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "volume_tags.brodo", "baggins"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, }, { // 2 defaultTags + 5 volumeTags (overlap) Config: testAccInstanceConfig_blockDeviceTagsDefaultVolumeRBDEBS(defTags, volTags3, emptyMap, emptyMap), @@ -1931,10 +1953,22 @@ func TestAccEC2Instance_BlockDeviceTags_defaultTagsVolumeTagsOverlap(t *testing. resource.TestCheckResourceAttr(resourceName, "volume_tags.iz", "paws"), // non-overlap resource.TestCheckResourceAttr(resourceName, "volume_tags.gigi", "kitty"), // non-overlap ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, }, { // 2 defaultTags + 5 volumeTags (overlap) - Config: testAccInstanceConfig_blockDeviceTagsDefaultVolumeRBDEBS(defTags, volTags3, emptyMap, emptyMap), - PlanOnly: true, + Config: testAccInstanceConfig_blockDeviceTagsDefaultVolumeRBDEBS(defTags, volTags3, emptyMap, emptyMap), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -5248,6 +5282,11 @@ func TestAccEC2Instance_UserData_emptyStringToUnspecified(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckInstanceExists(ctx, resourceName, &v), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -5257,9 +5296,15 @@ func TestAccEC2Instance_UserData_emptyStringToUnspecified(t *testing.T) { }, // Switching should show no difference { - Config: testAccInstanceConfig_userDataUnspecified(rName), - ExpectNonEmptyPlan: false, - PlanOnly: true, + Config: testAccInstanceConfig_userDataUnspecified(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -5282,6 +5327,11 @@ func TestAccEC2Instance_UserData_unspecifiedToEmptyString(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckInstanceExists(ctx, resourceName, &v), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -5293,7 +5343,14 @@ func TestAccEC2Instance_UserData_unspecifiedToEmptyString(t *testing.T) { { Config: testAccInstanceConfig_userDataEmptyString(rName), ExpectNonEmptyPlan: false, - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -5651,6 +5708,11 @@ func TestAccEC2Instance_CapacityReservation_unspecifiedDefaultsToOpen(t *testing resource.TestCheckResourceAttr(resourceName, "capacity_reservation_specification.0.capacity_reservation_preference", "open"), resource.TestCheckResourceAttr(resourceName, "capacity_reservation_specification.0.capacity_reservation_target.#", "0"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -5660,9 +5722,15 @@ func TestAccEC2Instance_CapacityReservation_unspecifiedDefaultsToOpen(t *testing }, // Adding 'open' preference should show no difference { - Config: testAccInstanceConfig_capacityReservationSpecificationPreference(rName, "open"), - ExpectNonEmptyPlan: false, - PlanOnly: true, + Config: testAccInstanceConfig_capacityReservationSpecificationPreference(rName, "open"), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_default_security_group_test.go b/internal/service/ec2/vpc_default_security_group_test.go index 8e12ef25194f..c43f74c56893 100644 --- a/internal/service/ec2/vpc_default_security_group_test.go +++ b/internal/service/ec2/vpc_default_security_group_test.go @@ -58,10 +58,6 @@ func TestAccVPCDefaultSecurityGroup_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "0"), ), }, - { - Config: testAccVPCDefaultSecurityGroupConfig_basic(rName), - PlanOnly: true, - }, { ResourceName: resourceName, ImportState: true, diff --git a/internal/service/ec2/vpc_default_vpc_dhcp_options_test.go b/internal/service/ec2/vpc_default_vpc_dhcp_options_test.go index bea180b0c993..bcc9e3892881 100644 --- a/internal/service/ec2/vpc_default_vpc_dhcp_options_test.go +++ b/internal/service/ec2/vpc_default_vpc_dhcp_options_test.go @@ -9,6 +9,7 @@ import ( "github.com/YakDriver/regexache" awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -102,11 +103,23 @@ func testAccDefaultVPCDHCPOptions_v420Regression(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDHCPOptionsExists(ctx, resourceName, &d), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Config: testAccVPCDefaultVPCDHCPOptionsConfig_basic, - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_network_acl_rule_test.go b/internal/service/ec2/vpc_network_acl_rule_test.go index b495fa7b59ad..f017f1d1741a 100644 --- a/internal/service/ec2/vpc_network_acl_rule_test.go +++ b/internal/service/ec2/vpc_network_acl_rule_test.go @@ -14,6 +14,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -296,10 +297,22 @@ func TestAccVPCNetworkACLRule_allProtocol(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "rule_number", "150"), resource.TestCheckResourceAttr(resourceName, "to_port", "22"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccVPCNetworkACLRuleConfig_allProtocolNoRealUpdate(rName), - PlanOnly: true, + Config: testAccVPCNetworkACLRuleConfig_allProtocolNoRealUpdate(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -329,10 +342,22 @@ func TestAccVPCNetworkACLRule_tcpProtocol(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "rule_number", "150"), resource.TestCheckResourceAttr(resourceName, "to_port", "22"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccVPCNetworkACLRuleConfig_tcpProtocolNoRealUpdate(rName), - PlanOnly: true, + Config: testAccVPCNetworkACLRuleConfig_tcpProtocolNoRealUpdate(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_route_table_test.go b/internal/service/ec2/vpc_route_table_test.go index 2761fe8e17fa..09fa726147e2 100644 --- a/internal/service/ec2/vpc_route_table_test.go +++ b/internal/service/ec2/vpc_route_table_test.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -219,6 +220,11 @@ func TestAccVPCRouteTable_ipv6ToEgressOnlyInternetGateway(t *testing.T) { resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -227,8 +233,15 @@ func TestAccVPCRouteTable_ipv6ToEgressOnlyInternetGateway(t *testing.T) { }, { // Verify that expanded form of the destination CIDR causes no diff. - Config: testAccVPCRouteTableConfig_ipv6EgressOnlyInternetGateway(rName, "::0/0"), - PlanOnly: true, + Config: testAccVPCRouteTableConfig_ipv6EgressOnlyInternetGateway(rName, "::0/0"), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_route_test.go b/internal/service/ec2/vpc_route_test.go index 8a4e23ff200e..e2bc722ae23d 100644 --- a/internal/service/ec2/vpc_route_test.go +++ b/internal/service/ec2/vpc_route_test.go @@ -13,6 +13,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -160,6 +161,11 @@ func TestAccVPCRoute_ipv6ToEgressOnlyInternetGateway(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrVPCEndpointID, ""), resource.TestCheckResourceAttr(resourceName, "vpc_peering_connection_id", ""), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -169,8 +175,15 @@ func TestAccVPCRoute_ipv6ToEgressOnlyInternetGateway(t *testing.T) { }, { // Verify that expanded form of the destination CIDR causes no diff. - Config: testAccVPCRouteConfig_ipv6EgressOnlyInternetGateway(rName, "::0/0"), - PlanOnly: true, + Config: testAccVPCRouteConfig_ipv6EgressOnlyInternetGateway(rName, "::0/0"), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_security_group_ingress_rule_test.go b/internal/service/ec2/vpc_security_group_ingress_rule_test.go index 3872e4321968..f9bb9385138b 100644 --- a/internal/service/ec2/vpc_security_group_ingress_rule_test.go +++ b/internal/service/ec2/vpc_security_group_ingress_rule_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -143,6 +144,11 @@ func TestAccVPCSecurityGroupIngressRule_tags_defaultAndIgnoreTags(t *testing.T) testAccCheckSecurityGroupIngressRuleExists(ctx, resourceName, &v), testAccCheckSecurityGroupIngressRuleUpdateTags(ctx, &v, nil, map[string]string{"defaultkey1": "defaultvalue1"}), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ExpectNonEmptyPlan: true, }, { @@ -150,14 +156,28 @@ func TestAccVPCSecurityGroupIngressRule_tags_defaultAndIgnoreTags(t *testing.T) acctest.ConfigDefaultAndIgnoreTagsKeyPrefixes1("defaultkey1", "defaultvalue1", "defaultkey"), testAccVPCSecurityGroupIngressRuleConfig_tags1(rName, acctest.CtKey1, acctest.CtValue1), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { Config: acctest.ConfigCompose( acctest.ConfigDefaultAndIgnoreTagsKeys1("defaultkey1", "defaultvalue1"), testAccVPCSecurityGroupIngressRuleConfig_tags1(rName, acctest.CtKey1, acctest.CtValue1), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -181,6 +201,11 @@ func TestAccVPCSecurityGroupIngressRule_tags_ignoreTags(t *testing.T) { testAccCheckSecurityGroupIngressRuleExists(ctx, resourceName, &v), testAccCheckSecurityGroupIngressRuleUpdateTags(ctx, &v, nil, map[string]string{"ignorekey1": "ignorevalue1"}), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ExpectNonEmptyPlan: true, }, { @@ -188,14 +213,28 @@ func TestAccVPCSecurityGroupIngressRule_tags_ignoreTags(t *testing.T) { acctest.ConfigIgnoreTagsKeyPrefixes1("ignorekey"), testAccVPCSecurityGroupIngressRuleConfig_basic(rName), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { Config: acctest.ConfigCompose( acctest.ConfigIgnoreTagsKeys("ignorekey1"), testAccVPCSecurityGroupIngressRuleConfig_basic(rName), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_security_group_test.go b/internal/service/ec2/vpc_security_group_test.go index 9817913b2f84..7f8ef93755fd 100644 --- a/internal/service/ec2/vpc_security_group_test.go +++ b/internal/service/ec2/vpc_security_group_test.go @@ -19,6 +19,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -954,6 +955,11 @@ func TestAccVPCSecurityGroup_noVPC(t *testing.T) { testAccCheckSecurityGroupExists(ctx, resourceName, &group), resource.TestCheckResourceAttrPair(resourceName, names.AttrVPCID, "data.aws_vpc.default", names.AttrID), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -962,12 +968,26 @@ func TestAccVPCSecurityGroup_noVPC(t *testing.T) { ImportStateVerifyIgnore: []string{"revoke_rules_on_delete"}, }, { - Config: testAccVPCSecurityGroupConfig_defaultVPC(rName), - PlanOnly: true, + Config: testAccVPCSecurityGroupConfig_defaultVPC(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { - Config: testAccVPCSecurityGroupConfig_noVPC(rName), - PlanOnly: true, + Config: testAccVPCSecurityGroupConfig_noVPC(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -2627,6 +2647,11 @@ func TestAccVPCSecurityGroup_rulesDropOnError(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckSecurityGroupExists(ctx, resourceName, &group), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, // Add a bad rule to trigger API error { @@ -2635,8 +2660,15 @@ func TestAccVPCSecurityGroup_rulesDropOnError(t *testing.T) { }, // All originally added rules must survive. This will return non-empty plan if anything changed. { - Config: testAccVPCSecurityGroupConfig_rulesDropOnErrorInit(rName), - PlanOnly: true, + Config: testAccVPCSecurityGroupConfig_rulesDropOnErrorInit(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_subnet_test.go b/internal/service/ec2/vpc_subnet_test.go index 7eb4ab20631c..0181a3d4e12c 100644 --- a/internal/service/ec2/vpc_subnet_test.go +++ b/internal/service/ec2/vpc_subnet_test.go @@ -13,6 +13,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -82,6 +83,11 @@ func TestAccVPCSubnet_tags_defaultAndIgnoreTags(t *testing.T) { testAccCheckSubnetExists(ctx, resourceName, &subnet), testAccCheckSubnetUpdateTags(ctx, &subnet, nil, map[string]string{"defaultkey1": "defaultvalue1"}), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ExpectNonEmptyPlan: true, }, { @@ -89,14 +95,28 @@ func TestAccVPCSubnet_tags_defaultAndIgnoreTags(t *testing.T) { acctest.ConfigDefaultAndIgnoreTagsKeyPrefixes1("defaultkey1", "defaultvalue1", "defaultkey"), testAccVPCSubnetConfig_tags1(rName, acctest.CtKey1, acctest.CtValue1), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { Config: acctest.ConfigCompose( acctest.ConfigDefaultAndIgnoreTagsKeys1("defaultkey1", "defaultvalue1"), testAccVPCSubnetConfig_tags1(rName, acctest.CtKey1, acctest.CtValue1), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -120,15 +140,34 @@ func TestAccVPCSubnet_tags_ignoreTags(t *testing.T) { testAccCheckSubnetExists(ctx, resourceName, &subnet), testAccCheckSubnetUpdateTags(ctx, &subnet, nil, map[string]string{"ignorekey1": "ignorevalue1"}), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ExpectNonEmptyPlan: true, }, { - Config: acctest.ConfigCompose(acctest.ConfigIgnoreTagsKeyPrefixes1("ignorekey"), testAccVPCSubnetConfig_basic(rName)), - PlanOnly: true, + Config: acctest.ConfigCompose(acctest.ConfigIgnoreTagsKeyPrefixes1("ignorekey"), testAccVPCSubnetConfig_basic(rName)), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { - Config: acctest.ConfigCompose(acctest.ConfigIgnoreTagsKeys("ignorekey1"), testAccVPCSubnetConfig_basic(rName)), - PlanOnly: true, + Config: acctest.ConfigCompose(acctest.ConfigIgnoreTagsKeys("ignorekey1"), testAccVPCSubnetConfig_basic(rName)), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ec2/vpc_test.go b/internal/service/ec2/vpc_test.go index 252901e561d3..c964fcd93e2b 100644 --- a/internal/service/ec2/vpc_test.go +++ b/internal/service/ec2/vpc_test.go @@ -222,6 +222,11 @@ func TestAccVPC_tags_defaultAndIgnoreTags(t *testing.T) { acctest.CheckVPCExists(ctx, resourceName, &vpc), testAccCheckVPCUpdateTags(ctx, &vpc, nil, map[string]string{"defaultkey1": "defaultvalue1"}), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ExpectNonEmptyPlan: true, }, { @@ -229,14 +234,28 @@ func TestAccVPC_tags_defaultAndIgnoreTags(t *testing.T) { acctest.ConfigDefaultAndIgnoreTagsKeyPrefixes1("defaultkey1", "defaultvalue1", "defaultkey"), testAccVPCConfig_tags1(acctest.CtKey1, acctest.CtValue1), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { Config: acctest.ConfigCompose( acctest.ConfigDefaultAndIgnoreTagsKeys1("defaultkey1", "defaultvalue1"), testAccVPCConfig_tags1(acctest.CtKey1, acctest.CtValue1), ), - PlanOnly: true, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -259,15 +278,34 @@ func TestAccVPC_tags_ignoreTags(t *testing.T) { acctest.CheckVPCExists(ctx, resourceName, &vpc), testAccCheckVPCUpdateTags(ctx, &vpc, nil, map[string]string{"ignorekey1": "ignorevalue1"}), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, ExpectNonEmptyPlan: true, }, { - Config: acctest.ConfigIgnoreTagsKeyPrefixes1("ignorekey") + testAccVPCConfig_tags1(acctest.CtKey1, acctest.CtValue1), - PlanOnly: true, + Config: acctest.ConfigIgnoreTagsKeyPrefixes1("ignorekey") + testAccVPCConfig_tags1(acctest.CtKey1, acctest.CtValue1), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { - Config: acctest.ConfigIgnoreTagsKeys("ignorekey1") + testAccVPCConfig_tags1(acctest.CtKey1, acctest.CtValue1), - PlanOnly: true, + Config: acctest.ConfigIgnoreTagsKeys("ignorekey1") + testAccVPCConfig_tags1(acctest.CtKey1, acctest.CtValue1), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 04d768fa464b701395eb3c1fc45b0e0fecce7146 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 16:23:31 -0400 Subject: [PATCH 19/27] ecr: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/sdkv2/schema.go | 20 +++++- internal/service/ecr/lifecycle_policy.go | 6 +- internal/service/ecr/lifecycle_policy_test.go | 45 ++++++++++--- .../ecr/repository_creation_template.go | 18 +----- .../ecr/repository_creation_template_test.go | 17 ++++- internal/service/ecr/repository_policy.go | 14 +--- .../service/ecr/repository_policy_test.go | 25 +++++++- internal/service/ecr/repository_test.go | 64 +++++++++++++------ 8 files changed, 145 insertions(+), 64 deletions(-) diff --git a/internal/sdkv2/schema.go b/internal/sdkv2/schema.go index efa6385056ac..946beb8b94ee 100644 --- a/internal/sdkv2/schema.go +++ b/internal/sdkv2/schema.go @@ -68,14 +68,30 @@ func ComputedOnlyFromResourceSchema(rs map[string]*schema.Schema) map[string]*sc return cs } +// IAMPolicyDocumentSchemaRequired returns the standard schema for an optional IAM policy JSON document. +var IAMPolicyDocumentSchemaOptional = sync.OnceValue(jsonDocumentSchemaOptionalFunc(SuppressEquivalentIAMPolicyDocuments)) + // IAMPolicyDocumentSchemaOptionalComputed returns the standard schema for an optional, computed IAM policy JSON document. var IAMPolicyDocumentSchemaOptionalComputed = sync.OnceValue(jsonDocumentSchemaOptionalComputedFunc(SuppressEquivalentIAMPolicyDocuments)) +// IAMPolicyDocumentSchemaRequired returns the standard schema for a required IAM policy JSON document. +var IAMPolicyDocumentSchemaRequired = sync.OnceValue(jsonDocumentSchemaRequiredFunc(SuppressEquivalentIAMPolicyDocuments)) + // JSONDocumentSchemaRequired returns the standard schema for a required JSON document. var JSONDocumentSchemaRequired = sync.OnceValue(jsonDocumentSchemaRequiredFunc(SuppressEquivalentJSONDocuments)) -// IAMPolicyDocumentSchemaRequired returns the standard schema for a required IAM policy JSON document. -var IAMPolicyDocumentSchemaRequired = sync.OnceValue(jsonDocumentSchemaRequiredFunc(SuppressEquivalentIAMPolicyDocuments)) +func jsonDocumentSchemaOptionalFunc(diffSuppressFunc schema.SchemaDiffSuppressFunc) func() *schema.Schema { + return func() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringIsJSON, + DiffSuppressFunc: diffSuppressFunc, + DiffSuppressOnRefresh: true, + StateFunc: NormalizeJsonStringSchemaStateFunc, + } + } +} func jsonDocumentSchemaOptionalComputedFunc(diffSuppressFunc schema.SchemaDiffSuppressFunc) func() *schema.Schema { return func() *schema.Schema { diff --git a/internal/service/ecr/lifecycle_policy.go b/internal/service/ecr/lifecycle_policy.go index 1c1749c7477d..c2bf61f7fdfe 100644 --- a/internal/service/ecr/lifecycle_policy.go +++ b/internal/service/ecr/lifecycle_policy.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tfjson "github.com/hashicorp/terraform-provider-aws/internal/json" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -48,10 +49,7 @@ func resourceLifecyclePolicy() *schema.Resource { return equal }, DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, + StateFunc: sdkv2.NormalizeJsonStringSchemaStateFunc, }, "registry_id": { Type: schema.TypeString, diff --git a/internal/service/ecr/lifecycle_policy_test.go b/internal/service/ecr/lifecycle_policy_test.go index eb6f8fa26eef..edfa4addf3c7 100644 --- a/internal/service/ecr/lifecycle_policy_test.go +++ b/internal/service/ecr/lifecycle_policy_test.go @@ -10,6 +10,7 @@ import ( sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -83,10 +84,22 @@ func TestAccECRLifecyclePolicy_ignoreEquivalent(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLifecyclePolicyExists(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccLifecyclePolicyConfig_newOrder(rName), - PlanOnly: true, + Config: testAccLifecyclePolicyConfig_newOrder(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -108,11 +121,19 @@ func TestAccECRLifecyclePolicy_detectDiff(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLifecyclePolicyExists(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccLifecyclePolicyConfig_changed(rName), - ExpectNonEmptyPlan: true, - PlanOnly: true, + Config: testAccLifecyclePolicyConfig_changed(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace), + }, + }, }, }, }) @@ -134,11 +155,19 @@ func TestAccECRLifecyclePolicy_detectTagPatternListDiff(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLifecyclePolicyExists(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccLifecyclePolicyConfig_tagPatternListChanged(rName), - ExpectNonEmptyPlan: true, - PlanOnly: true, + Config: testAccLifecyclePolicyConfig_tagPatternListChanged(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace), + }, + }, }, }, }) diff --git a/internal/service/ecr/repository_creation_template.go b/internal/service/ecr/repository_creation_template.go index 8968854c8a49..e720b08bd987 100644 --- a/internal/service/ecr/repository_creation_template.go +++ b/internal/service/ecr/repository_creation_template.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -94,10 +95,7 @@ func resourceRepositoryCreationTemplate() *schema.Resource { return equal }, DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, + StateFunc: sdkv2.NormalizeJsonStringSchemaStateFunc, }, names.AttrPrefix: { Type: schema.TypeString, @@ -114,17 +112,7 @@ func resourceRepositoryCreationTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "repository_policy": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringIsJSON, - DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs, - DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, - }, + "repository_policy": sdkv2.IAMPolicyDocumentSchemaOptional(), names.AttrResourceTags: tftags.TagsSchema(), }, } diff --git a/internal/service/ecr/repository_creation_template_test.go b/internal/service/ecr/repository_creation_template_test.go index ddc462f2aaf1..e9480a258e5b 100644 --- a/internal/service/ecr/repository_creation_template_test.go +++ b/internal/service/ecr/repository_creation_template_test.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ecr/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -118,10 +119,22 @@ func TestAccECRRepositoryCreationTemplate_ignoreEquivalentLifecycle(t *testing.T Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryCreationTemplateExists(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccRepositoryCreationTemplateConfig_lifecycleNewOrder(repositoryPrefix), - PlanOnly: true, + Config: testAccRepositoryCreationTemplateConfig_lifecycleNewOrder(repositoryPrefix), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ecr/repository_policy.go b/internal/service/ecr/repository_policy.go index 86b617976ffb..fc7341a76420 100644 --- a/internal/service/ecr/repository_policy.go +++ b/internal/service/ecr/repository_policy.go @@ -14,10 +14,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" @@ -36,17 +36,7 @@ func resourceRepositoryPolicy() *schema.Resource { }, Schema: map[string]*schema.Schema{ - names.AttrPolicy: { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsJSON, - DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs, - DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, - }, + names.AttrPolicy: sdkv2.IAMPolicyDocumentSchemaRequired(), "registry_id": { Type: schema.TypeString, Computed: true, diff --git a/internal/service/ecr/repository_policy_test.go b/internal/service/ecr/repository_policy_test.go index 902c1cfa0b19..7773e775196b 100644 --- a/internal/service/ecr/repository_policy_test.go +++ b/internal/service/ecr/repository_policy_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -105,16 +106,36 @@ func TestAccECRRepositoryPolicy_IAM_principalOrder(t *testing.T) { resource.TestMatchResourceAttr(resourceName, names.AttrPolicy, regexache.MustCompile(rName)), resource.TestMatchResourceAttr(resourceName, names.AttrPolicy, regexache.MustCompile("iam")), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { Config: testAccRepositoryPolicyConfig_iamRoleNewOrderJSONEncode(rName), Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryPolicyExists(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { - Config: testAccRepositoryPolicyConfig_iamRoleOrderJSONEncode(rName), - PlanOnly: true, + Config: testAccRepositoryPolicyConfig_iamRoleOrderJSONEncode(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/ecr/repository_test.go b/internal/service/ecr/repository_test.go index 8346220f9f78..e0f9b66b24ac 100644 --- a/internal/service/ecr/repository_test.go +++ b/internal/service/ecr/repository_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ecr/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -175,6 +176,11 @@ func TestAccECRRepository_Image_scanning(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "image_scanning_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "image_scanning_configuration.0.scan_on_push", acctest.CtTrue), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -183,9 +189,12 @@ func TestAccECRRepository_Image_scanning(t *testing.T) { }, { // Test that the removal of the non-default image_scanning_configuration causes plan changes - Config: testAccRepositoryConfig_basic(rName), - PlanOnly: true, - ExpectNonEmptyPlan: true, + Config: testAccRepositoryConfig_basic(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, }, { // Test attribute update @@ -195,12 +204,23 @@ func TestAccECRRepository_Image_scanning(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "image_scanning_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "image_scanning_configuration.0.scan_on_push", acctest.CtFalse), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { // Test that the removal of the default image_scanning_configuration doesn't cause any plan changes - Config: testAccRepositoryConfig_basic(rName), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccRepositoryConfig_basic(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -271,16 +291,25 @@ func TestAccECRRepository_Encryption_aes256(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryExists(ctx, resourceName, &v1), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { Config: testAccRepositoryConfig_encryptionAES256(rName), Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryExists(ctx, resourceName, &v2), - testAccCheckRepositoryNotRecreated(&v1, &v2), resource.TestCheckResourceAttr(resourceName, "encryption_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "encryption_configuration.0.encryption_type", string(types.EncryptionTypeAes256)), resource.TestCheckResourceAttr(resourceName, "encryption_configuration.0.kms_key", ""), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { ResourceName: resourceName, @@ -289,8 +318,15 @@ func TestAccECRRepository_Encryption_aes256(t *testing.T) { }, { // Test that the removal of the default encryption_configuration doesn't cause any plan changes - Config: testAccRepositoryConfig_basic(rName), - PlanOnly: true, + Config: testAccRepositoryConfig_basic(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -370,16 +406,6 @@ func testAccCheckRepositoryRecreated(i, j *types.Repository) resource.TestCheckF } } -func testAccCheckRepositoryNotRecreated(i, j *types.Repository) resource.TestCheckFunc { // nosemgrep:ci.ecr-in-func-name - return func(s *terraform.State) error { - if !aws.ToTime(i.CreatedAt).Equal(aws.ToTime(j.CreatedAt)) { - return fmt.Errorf("ECR repository was recreated") - } - - return nil - } -} - func testAccRepositoryConfig_basic(rName string) string { return fmt.Sprintf(` resource "aws_ecr_repository" "test" { From 8abf4dacfc7440e83fbdba69355d2f89c8dc37d2 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 16:33:27 -0400 Subject: [PATCH 20/27] ecs: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/ecs/task_definition_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/service/ecs/task_definition_test.go b/internal/service/ecs/task_definition_test.go index ea17134ae842..9447fee9d319 100644 --- a/internal/service/ecs/task_definition_test.go +++ b/internal/service/ecs/task_definition_test.go @@ -980,6 +980,11 @@ func TestAccECSTaskDefinition_Fargate_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "cpu", "256"), resource.TestCheckResourceAttr(resourceName, "memory", "512"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -989,9 +994,15 @@ func TestAccECSTaskDefinition_Fargate_basic(t *testing.T) { ImportStateVerifyIgnore: []string{names.AttrSkipDestroy, "track_latest"}, }, { - ExpectNonEmptyPlan: false, - PlanOnly: true, - Config: testAccTaskDefinitionConfig_fargate(rName, `[{"protocol": "tcp", "containerPort": 8000, "hostPort": 8000}]`), + Config: testAccTaskDefinitionConfig_fargate(rName, `[{"protocol": "tcp", "containerPort": 8000, "hostPort": 8000}]`), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From de6adacabdb55c443799095245e4436804afd00c Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 16:36:19 -0400 Subject: [PATCH 21/27] efs: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/efs/file_system_policy.go | 14 ++------ .../service/efs/file_system_policy_test.go | 33 ++++++++++++++++--- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/internal/service/efs/file_system_policy.go b/internal/service/efs/file_system_policy.go index f92c0311dc01..a7ef616f6694 100644 --- a/internal/service/efs/file_system_policy.go +++ b/internal/service/efs/file_system_policy.go @@ -14,10 +14,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" @@ -46,17 +46,7 @@ func resourceFileSystemPolicy() *schema.Resource { Required: true, ForceNew: true, }, - names.AttrPolicy: { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsJSON, - DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs, - DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, - }, + names.AttrPolicy: sdkv2.IAMPolicyDocumentSchemaRequired(), }, } } diff --git a/internal/service/efs/file_system_policy_test.go b/internal/service/efs/file_system_policy_test.go index 16390fdff977..37f452b8fbbb 100644 --- a/internal/service/efs/file_system_policy_test.go +++ b/internal/service/efs/file_system_policy_test.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/efs" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -134,10 +135,22 @@ func TestAccEFSFileSystemPolicy_equivalentPolicies(t *testing.T) { testAccCheckFileSystemPolicyExists(ctx, resourceName, &desc), resource.TestCheckResourceAttrSet(resourceName, names.AttrPolicy), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccFileSystemPolicyConfig_secondEquivalent(rName), - PlanOnly: true, + Config: testAccFileSystemPolicyConfig_secondEquivalent(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -162,10 +175,22 @@ func TestAccEFSFileSystemPolicy_equivalentPoliciesIAMPolicyDoc(t *testing.T) { testAccCheckFileSystemPolicyExists(ctx, resourceName, &desc), resource.TestCheckResourceAttrSet(resourceName, names.AttrPolicy), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccFileSystemPolicyConfig_equivalentIAMDoc(rName), - PlanOnly: true, + Config: testAccFileSystemPolicyConfig_equivalentIAMDoc(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 5ac054ed97028429d219694daa9c110e3f9da11a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 17:02:55 -0400 Subject: [PATCH 22/27] eks: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/eks/cluster_test.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/internal/service/eks/cluster_test.go b/internal/service/eks/cluster_test.go index 3a3dd7b62bf6..13b2310e8bba 100644 --- a/internal/service/eks/cluster_test.go +++ b/internal/service/eks/cluster_test.go @@ -1121,9 +1121,15 @@ func TestAccEKSCluster_Network_serviceIPv4CIDR(t *testing.T) { ImportStateVerifyIgnore: []string{"bootstrap_self_managed_addons"}, }, { - Config: testAccClusterConfig_networkServiceIPv4CIDR(rName, `"192.168.0.0/24"`), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccClusterConfig_networkServiceIPv4CIDR(rName, `"192.168.0.0/24"`), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { Config: testAccClusterConfig_networkServiceIPv4CIDR(rName, `"192.168.1.0/24"`), @@ -1174,9 +1180,15 @@ func TestAccEKSCluster_Network_ipFamily(t *testing.T) { ImportStateVerifyIgnore: []string{"bootstrap_self_managed_addons"}, }, { - Config: testAccClusterConfig_networkIPFamily(rName, `"ipv6"`), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccClusterConfig_networkIPFamily(rName, `"ipv6"`), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { Config: testAccClusterConfig_networkIPFamily(rName, `"ipv4"`), From 7b24dd54d3d3608af65263d5aa8fc1218e0164c3 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Tue, 24 Jun 2025 19:14:44 -0400 Subject: [PATCH 23/27] elasticache: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- .../global_replication_group_test.go | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/internal/service/elasticache/global_replication_group_test.go b/internal/service/elasticache/global_replication_group_test.go index b6aead6a81ae..44e40491efcc 100644 --- a/internal/service/elasticache/global_replication_group_test.go +++ b/internal/service/elasticache/global_replication_group_test.go @@ -15,6 +15,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/elasticache/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -1186,7 +1187,6 @@ func TestAccElastiCacheGlobalReplicationGroup_SetParameterGroupOnCreate_NoVersio { Config: testAccGlobalReplicationGroupConfig_param(rName, primaryReplicationGroupId, "6.2", "default.redis6.x"), ExpectError: regexache.MustCompile(`cannot change parameter group name without upgrading major engine version`), - PlanOnly: true, }, }, }) @@ -1273,10 +1273,22 @@ func TestAccElastiCacheGlobalReplicationGroup_SetEngineVersionOnUpdate_MinorUpgr resource.TestCheckResourceAttrPair(resourceName, "engine_version_actual", primaryReplicationGroupResourceName, "engine_version_actual"), resource.TestMatchResourceAttr(resourceName, "engine_version_actual", regexache.MustCompile(`^6\.0\.[[:digit:]]+$`)), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccGlobalReplicationGroupConfig_Redis_engineVersion(rName, primaryReplicationGroupId, "6.0", "6.x"), - PlanOnly: true, + Config: testAccGlobalReplicationGroupConfig_Redis_engineVersion(rName, primaryReplicationGroupId, "6.0", "6.x"), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) @@ -1442,7 +1454,6 @@ func TestAccElastiCacheGlobalReplicationGroup_SetParameterGroupOnUpdate_NoVersio { Config: testAccGlobalReplicationGroupConfig_param(rName, primaryReplicationGroupId, "6.2", "default.redis6.x"), ExpectError: regexache.MustCompile(`cannot change parameter group name without upgrading major engine version`), - PlanOnly: true, }, }, }) @@ -1477,7 +1488,6 @@ func TestAccElastiCacheGlobalReplicationGroup_SetParameterGroupOnUpdate_MinorUpg { Config: testAccGlobalReplicationGroupConfig_engineVersionParam(rName, primaryReplicationGroupId, "6.0", "6.2", "default.redis6.x"), ExpectError: regexache.MustCompile(`cannot change parameter group name on minor engine version upgrade, upgrading from 6\.0\.[[:digit:]]+ to 6\.2\.[[:digit:]]+`), - PlanOnly: true, }, }, }) @@ -1513,7 +1523,6 @@ func TestAccElastiCacheGlobalReplicationGroup_UpdateParameterGroupName(t *testin { Config: testAccGlobalReplicationGroupConfig_engineVersionCustomParam(rName, primaryReplicationGroupId, "5.0.6", "6.2", parameterGroupName, "redis6.x"), ExpectError: regexache.MustCompile(`cannot change parameter group name without upgrading major engine version`), - PlanOnly: true, }, }, }) From 954b308305cfb3296f935d6abcc624455b84b5ad Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 25 Jun 2025 09:32:30 -0400 Subject: [PATCH 24/27] elasticsearch: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/elasticsearch/domain_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/service/elasticsearch/domain_test.go b/internal/service/elasticsearch/domain_test.go index 42244f44adef..0a6575faffb1 100644 --- a/internal/service/elasticsearch/domain_test.go +++ b/internal/service/elasticsearch/domain_test.go @@ -1296,10 +1296,22 @@ func TestAccElasticsearchDomain_policyIgnoreEquivalent(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName, &domain), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccDomainConfig_policyNewOrder(rName), - PlanOnly: true, + Config: testAccDomainConfig_policyNewOrder(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From 1f1ea58ae4f1d9ee018e960c746517bc345d9e65 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 25 Jun 2025 09:41:16 -0400 Subject: [PATCH 25/27] elb: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- .../service/elb/lb_ssl_negotiation_policy.go | 2 ++ .../elb/lb_ssl_negotiation_policy_test.go | 22 +++++++++++++++++-- internal/service/elb/listener_policy_test.go | 22 +++++++++++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/internal/service/elb/lb_ssl_negotiation_policy.go b/internal/service/elb/lb_ssl_negotiation_policy.go index 5c13c8a57cfe..75031c647dc2 100644 --- a/internal/service/elb/lb_ssl_negotiation_policy.go +++ b/internal/service/elb/lb_ssl_negotiation_policy.go @@ -38,10 +38,12 @@ func resourceSSLNegotiationPolicy() *schema.Resource { names.AttrName: { Type: schema.TypeString, Required: true, + ForceNew: true, }, names.AttrValue: { Type: schema.TypeString, Required: true, + ForceNew: true, }, }, }, diff --git a/internal/service/elb/lb_ssl_negotiation_policy_test.go b/internal/service/elb/lb_ssl_negotiation_policy_test.go index ac47ccabbdc4..6c493e78f68f 100644 --- a/internal/service/elb/lb_ssl_negotiation_policy_test.go +++ b/internal/service/elb/lb_ssl_negotiation_policy_test.go @@ -10,6 +10,7 @@ import ( sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -61,6 +62,11 @@ func TestAccELBSSLNegotiationPolicy_update(t *testing.T) { testAccCheckLBSSLNegotiationPolicy(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "attribute.#", "7"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { Config: testAccLBSSLNegotiationPolicyConfig_update(rName, key, certificate, 1), @@ -68,10 +74,22 @@ func TestAccELBSSLNegotiationPolicy_update(t *testing.T) { testAccCheckLBSSLNegotiationPolicy(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "attribute.#", "7"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace), + }, + }, }, { - Config: testAccLBSSLNegotiationPolicyConfig_update(rName, key, certificate, 1), - PlanOnly: true, + Config: testAccLBSSLNegotiationPolicyConfig_update(rName, key, certificate, 1), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/elb/listener_policy_test.go b/internal/service/elb/listener_policy_test.go index c2ee5edac507..47fce72b3057 100644 --- a/internal/service/elb/listener_policy_test.go +++ b/internal/service/elb/listener_policy_test.go @@ -10,6 +10,7 @@ import ( sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -63,6 +64,11 @@ func TestAccELBListenerPolicy_update(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "policy_names.#", "1"), resource.TestCheckTypeSetElemAttrPair(resourceName, "policy_names.*", "aws_load_balancer_policy.test", "policy_name"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { Config: testAccListenerPolicyConfig_update(rName, key, certificate, 1), @@ -72,10 +78,22 @@ func TestAccELBListenerPolicy_update(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "policy_names.#", "1"), resource.TestCheckTypeSetElemAttrPair(resourceName, "policy_names.*", "aws_load_balancer_policy.test", "policy_name"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, }, { - Config: testAccListenerPolicyConfig_update(rName, key, certificate, 1), - PlanOnly: true, + Config: testAccListenerPolicyConfig_update(rName, key, certificate, 1), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) From a68ce02a7ac17d09382ea0a3d577b0731df77b01 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 25 Jun 2025 09:54:41 -0400 Subject: [PATCH 26/27] elbv2: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/elbv2/listener_rule_test.go | 18 +++++- internal/service/elbv2/listener_test.go | 17 +++++- internal/service/elbv2/target_group_test.go | 60 +++++++++++++++----- 3 files changed, 74 insertions(+), 21 deletions(-) diff --git a/internal/service/elbv2/listener_rule_test.go b/internal/service/elbv2/listener_rule_test.go index 28f67c268a12..38181652614f 100644 --- a/internal/service/elbv2/listener_rule_test.go +++ b/internal/service/elbv2/listener_rule_test.go @@ -17,6 +17,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -1485,6 +1486,11 @@ func TestAccELBV2ListenerRule_redirectWithTargetGroupARN(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "action.0.forward.#", "0"), resource.TestCheckResourceAttr(resourceName, "action.0.target_group_arn", ""), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ExternalProviders: map[string]resource.ExternalProvider{ @@ -1493,9 +1499,15 @@ func TestAccELBV2ListenerRule_redirectWithTargetGroupARN(t *testing.T) { VersionConstraint: "5.36.0", }, }, - Config: testAccListenerRuleConfig_redirectWithTargetGroupARN(lbName), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccListenerRuleConfig_redirectWithTargetGroupARN(lbName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/elbv2/listener_test.go b/internal/service/elbv2/listener_test.go index f308349d3a90..475c5c2c1150 100644 --- a/internal/service/elbv2/listener_test.go +++ b/internal/service/elbv2/listener_test.go @@ -2186,6 +2186,11 @@ func TestAccELBV2Listener_redirectWithTargetGroupARN(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.forward.#", "0"), resource.TestCheckResourceAttr(resourceName, "default_action.0.target_group_arn", ""), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ExternalProviders: map[string]resource.ExternalProvider{ @@ -2194,9 +2199,15 @@ func TestAccELBV2Listener_redirectWithTargetGroupARN(t *testing.T) { VersionConstraint: "5.36.0", }, }, - Config: testAccListenerConfig_redirectWithTargetGroupARN(rName), - PlanOnly: true, - ExpectNonEmptyPlan: false, + Config: testAccListenerConfig_redirectWithTargetGroupARN(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/elbv2/target_group_test.go b/internal/service/elbv2/target_group_test.go index 5b799312dc54..a49782d5eb01 100644 --- a/internal/service/elbv2/target_group_test.go +++ b/internal/service/elbv2/target_group_test.go @@ -16,6 +16,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -1260,6 +1261,7 @@ func TestAccELBV2TargetGroup_Stickiness_defaultNLB(t *testing.T) { func TestAccELBV2TargetGroup_Stickiness_invalidALB(t *testing.T) { ctx := acctest.Context(t) rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_lb_target_group.test" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) }, @@ -1288,9 +1290,13 @@ func TestAccELBV2TargetGroup_Stickiness_invalidALB(t *testing.T) { ExpectError: regexache.MustCompile("You cannot enable stickiness on target groups with the TLS protocol"), }, { - Config: testAccTargetGroupConfig_stickinessValidity(rName, "TCP_UDP", "lb_cookie", false, "round_robin"), - PlanOnly: true, - ExpectNonEmptyPlan: true, + Config: testAccTargetGroupConfig_stickinessValidity(rName, "TCP_UDP", "lb_cookie", false, "round_robin"), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionReplace), + }, + }, + ExpectError: regexache.MustCompile("Stickiness type 'lb_cookie' is not supported for target groups with"), }, }, }) @@ -3716,7 +3722,7 @@ func TestAccELBV2TargetGroup_Instance_protocolVersion_MigrateV0(t *testing.T) { Config: testAccTargetGroupConfig_Instance_protocolVersion(protocol, "HTTP1"), PreCheck: preCheck, PostCheck: postCheck, - }.Steps(), + }.Steps(resourceName), }) }) } @@ -3788,7 +3794,7 @@ func TestAccELBV2TargetGroup_Lambda_defaults_MigrateV0(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "health_check.#", "1"), resource.TestCheckResourceAttr(resourceName, "health_check.0.enabled", acctest.CtFalse), ), - }.Steps(), + }.Steps(resourceName), }) } @@ -3840,7 +3846,7 @@ func TestAccELBV2TargetGroup_Lambda_vpc_MigrateV0(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target_type", string(awstypes.TargetTypeEnumLambda)), resource.TestCheckResourceAttr(resourceName, names.AttrVPCID, ""), // Should be Null ), - }.Steps(), + }.Steps(resourceName), }) } @@ -3906,7 +3912,7 @@ func TestAccELBV2TargetGroup_Lambda_protocol_MigrateV0(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target_type", string(awstypes.TargetTypeEnumLambda)), resource.TestCheckResourceAttr(resourceName, names.AttrProtocol, ""), // Should be Null ), - }.Steps(), + }.Steps(resourceName), }) }) } @@ -3960,7 +3966,7 @@ func TestAccELBV2TargetGroup_Lambda_protocolVersion_MigrateV0(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target_type", string(awstypes.TargetTypeEnumLambda)), resource.TestCheckNoResourceAttr(resourceName, "protocol_version"), ), - }.Steps(), + }.Steps(resourceName), }) } @@ -4012,7 +4018,7 @@ func TestAccELBV2TargetGroup_Lambda_port_MigrateV0(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target_type", string(awstypes.TargetTypeEnumLambda)), resource.TestCheckResourceAttr(resourceName, names.AttrPort, "0"), // Should be Null ), - }.Steps(), + }.Steps(resourceName), }) } @@ -4088,7 +4094,7 @@ func TestAccELBV2TargetGroup_Lambda_HealthCheck_basic_MigrateV0(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "health_check.0.timeout", "35"), resource.TestCheckResourceAttr(resourceName, "health_check.0.unhealthy_threshold", "3"), ), - }.Steps(), + }.Steps(resourceName), }) } @@ -4203,6 +4209,11 @@ func TestAccELBV2TargetGroup_Lambda_HealthCheck_protocol_MigrateV0(t *testing.T) resource.TestCheckResourceAttr(resourceName, "health_check.0.enabled", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "health_check.0.protocol", ""), ) + step.ConfigPlanChecks = resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + } } else { t.Fatal("invalid test case, one of invalidHealthCheckProtocol or warning must be set") } @@ -4217,8 +4228,15 @@ func TestAccELBV2TargetGroup_Lambda_HealthCheck_protocol_MigrateV0(t *testing.T) VersionConstraint: "5.26.0", }, }, - Config: config, - PlanOnly: true, + Config: config, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }) } @@ -4332,7 +4350,7 @@ type testAccMigrateTest struct { PostCheck resource.TestCheckFunc } -func (t testAccMigrateTest) Steps() []resource.TestStep { +func (t testAccMigrateTest) Steps(resourceName string) []resource.TestStep { return []resource.TestStep{ { ExternalProviders: map[string]resource.ExternalProvider{ @@ -4343,6 +4361,11 @@ func (t testAccMigrateTest) Steps() []resource.TestStep { }, Config: t.Config, Check: t.PreCheck, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ExternalProviders: map[string]resource.ExternalProvider{ @@ -4351,8 +4374,15 @@ func (t testAccMigrateTest) Steps() []resource.TestStep { VersionConstraint: t.NextVersion, }, }, - Config: t.Config, - PlanOnly: true, + Config: t.Config, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, { ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, From 98fa76df147c83c9385a08f368c1be07c4aba0bd Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Wed, 25 Jun 2025 10:44:08 -0400 Subject: [PATCH 27/27] events: Replace 'PlanOnly' acceptance test steps with 'plancheck's. --- internal/service/events/bus_policy.go | 14 ++------------ internal/service/events/bus_policy_test.go | 17 +++++++++++++++-- internal/service/events/permission_test.go | 22 ++++++++++++++++++++-- internal/service/events/target_test.go | 17 +++++++++++++++-- 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/internal/service/events/bus_policy.go b/internal/service/events/bus_policy.go index 21744c559215..52a9683d0153 100644 --- a/internal/service/events/bus_policy.go +++ b/internal/service/events/bus_policy.go @@ -14,10 +14,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/internal/sdkv2" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" @@ -46,17 +46,7 @@ func resourceBusPolicy() *schema.Resource { ValidateFunc: validBusName, Default: DefaultEventBusName, }, - names.AttrPolicy: { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsJSON, - DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs, - DiffSuppressOnRefresh: true, - StateFunc: func(v any) string { - json, _ := structure.NormalizeJsonString(v) - return json - }, - }, + names.AttrPolicy: sdkv2.IAMPolicyDocumentSchemaRequired(), }, } } diff --git a/internal/service/events/bus_policy_test.go b/internal/service/events/bus_policy_test.go index 8058b4e79192..1e61ce812ca4 100644 --- a/internal/service/events/bus_policy_test.go +++ b/internal/service/events/bus_policy_test.go @@ -13,6 +13,7 @@ import ( awspolicy "github.com/hashicorp/awspolicyequivalence" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -72,10 +73,22 @@ func TestAccEventsBusPolicy_ignoreEquivalent(t *testing.T) { testAccCheckBusPolicyExists(ctx, resourceName), testAccBusPolicyDocument(ctx, resourceName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { - Config: testAccBusPolicyConfig_newOrder(rName), - PlanOnly: true, + Config: testAccBusPolicyConfig_newOrder(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/events/permission_test.go b/internal/service/events/permission_test.go index dbfa594e77bf..a4a585f6cb21 100644 --- a/internal/service/events/permission_test.go +++ b/internal/service/events/permission_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -70,6 +71,11 @@ func TestAccEventsPermission_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "statement_id", statementID), resource.TestCheckResourceAttr(resourceName, "event_bus_name", tfevents.DefaultEventBusName), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { Config: testAccPermissionConfig_basic(principal2, statementID), @@ -77,6 +83,11 @@ func TestAccEventsPermission_basic(t *testing.T) { testAccCheckPermissionExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, principal2), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionUpdate), + }, + }, }, { ResourceName: resourceName, @@ -84,8 +95,15 @@ func TestAccEventsPermission_basic(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccPermissionConfig_defaultBusName(principal2, statementID), - PlanOnly: true, + Config: testAccPermissionConfig_defaultBusName(principal2, statementID), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, }) diff --git a/internal/service/events/target_test.go b/internal/service/events/target_test.go index 71630c7bca1a..053fb7d5860e 100644 --- a/internal/service/events/target_test.go +++ b/internal/service/events/target_test.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -228,6 +229,11 @@ func TestAccEventsTarget_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target_id", rName), resource.TestCheckResourceAttr(resourceName, "appsync_target.#", "0"), ), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate), + }, + }, }, { ResourceName: resourceName, @@ -244,8 +250,15 @@ func TestAccEventsTarget_basic(t *testing.T) { ImportStateVerifyIgnore: []string{names.AttrForceDestroy}, }, { - Config: testAccTargetConfig_defaultBusName(rName), - PlanOnly: true, + Config: testAccTargetConfig_defaultBusName(rName), + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + PostApplyPostRefresh: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionNoop), + }, + }, }, }, })