Skip to content

Technical debt: Replace PlanOnly acceptance tests (services a - e) #43146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d5ec083
apigateway: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 23, 2025
9e6484e
Fix 'testAccAccount_basic'.
ewbankkit Jun 23, 2025
914b591
r/aws_api_gateway_base_path_mapping: Fixup acceptance tests.
ewbankkit Jun 23, 2025
a807357
Fix terrafmt errors.
ewbankkit Jun 23, 2025
2a4d17e
appconfig: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 23, 2025
8a795dc
Remove unneccessary PlanOnly test cases.
ewbankkit Jun 23, 2025
9f4d1c2
appstream: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 23, 2025
644be0a
backup: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 23, 2025
ef55161
cloudformation: Replace 'PlanOnly' acceptance test steps with 'planch…
ewbankkit Jun 23, 2025
d556b62
codeartifact: Replace 'PlanOnly' acceptance test steps with 'planchec…
ewbankkit Jun 23, 2025
07d5b5e
Remove unneccessary PlanOnly test cases.
ewbankkit Jun 23, 2025
1b8a667
cognitoidp: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 23, 2025
f62780c
comprehend: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 23, 2025
4720bb9
dax: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
1b8ad46
dms: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
26e8cc3
ds: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
2b2f2c4
dynamodb: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
9824660
ec2: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
04d768f
ecr: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
8abf4da
ecs: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
de6adac
efs: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
5ac054e
eks: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
7b24dd5
elasticache: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 24, 2025
954b308
elasticsearch: Replace 'PlanOnly' acceptance test steps with 'planche…
ewbankkit Jun 25, 2025
1f1ea58
elb: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 25, 2025
a68ce02
elbv2: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 25, 2025
98fa76d
events: Replace 'PlanOnly' acceptance test steps with 'plancheck's.
ewbankkit Jun 25, 2025
7be8867
Merge branch 'main' into td-replace-PlanOnly-test-steps
ewbankkit Jun 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions internal/sdkv2/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,33 @@ 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))

// JSONDocumentSchemaRequired returns the standard schema for an optional, force-new JSON document.
// IAMPolicyDocumentSchemaRequired returns the standard schema for a required IAM policy JSON document.
var IAMPolicyDocumentSchemaRequired = sync.OnceValue(jsonDocumentSchemaRequiredFunc(SuppressEquivalentIAMPolicyDocuments))

// JSONDocumentSchemaOptionalForceNew returns the standard schema for an optional, force-new JSON document.
var JSONDocumentSchemaOptionalForceNew = sync.OnceValue(jsonDocumentSchemaOptionalForceNewFunc(SuppressEquivalentJSONDocuments))

// 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 {
Expand Down
44 changes: 40 additions & 4 deletions internal/service/apigateway/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ 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"
"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"
Expand All @@ -39,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),
Expand Down Expand Up @@ -162,14 +164,29 @@ 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("")),
},
},
{
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("")),
},
},
},
})
Expand All @@ -195,6 +212,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"),
Expand All @@ -206,7 +228,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(),
),
},
},
},
})
Expand Down
54 changes: 42 additions & 12 deletions internal/service/apigateway/base_path_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
},
},
},
},
})
Expand Down Expand Up @@ -359,8 +372,18 @@ 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]

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))
}
Expand All @@ -370,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))
Expand Down Expand Up @@ -440,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]

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
}
Expand All @@ -465,9 +498,7 @@ resource "aws_api_gateway_rest_api" "test2" {
}
}


resource "aws_api_gateway_stage" "test2" {

depends_on = [
aws_api_gateway_deployment.test
]
Expand Down Expand Up @@ -497,11 +528,10 @@ 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]

depends_on = [aws_api_gateway_integration.test2]
}

resource "aws_api_gateway_base_path_mapping" "test" {
Expand Down
29 changes: 27 additions & 2 deletions internal/service/apigateway/domain_name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()),
},
},
},
})
Expand Down
29 changes: 26 additions & 3 deletions internal/service/apigateway/rest_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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),
},
},
},
},
})
Expand Down
Loading
Loading