Skip to content

[WIP] Resource Identity #42487

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
170 commits merged into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
c182f9c
Updates dependencies
gdavison Mar 24, 2025
ee688a2
Adds `tfknownvalue.AccountID()` check
gdavison Mar 29, 2025
76c88d9
Adds identity to `aws_s3_bucket`
gdavison Mar 29, 2025
16cc037
Uses `acctest.CheckResourceAttrRegionalARNFormat` for ARN checks for …
gdavison Apr 1, 2025
6579549
Uses `acctest.CheckResourceAttrRegionalARNFormat` for ARN checks for …
gdavison Apr 1, 2025
c9d49b0
Adds import test steps for `aws_s3_bucket`
gdavison Apr 1, 2025
58c283e
Constants
gdavison Apr 1, 2025
9c740c5
Adds identity to `aws_route53_record`
gdavison Apr 1, 2025
231e4a6
Adds identity to `aws_iam_role`
gdavison Apr 1, 2025
3cb89bc
Adds identity to `aws_batch_job_definition`
gdavison Apr 1, 2025
cae6e52
Implements `ResourceWithIdentity` on Framework `wrappedResource`
gdavison Apr 1, 2025
20440bb
Adds `ExpectIdentityRegionalARNFormat` state check
gdavison Apr 1, 2025
173a107
Adds identity to `aws_batch_job_queue`
gdavison Apr 1, 2025
0ab828d
Adds identity interceptor for SDKv2
gdavison Apr 2, 2025
e1c8a22
Renames service package template
gdavison Apr 2, 2025
27513f3
Adds parameterized identity to SDK resource generation
gdavison Apr 2, 2025
bfd1310
Enables generated Identity for `aws_s3_bucket`
gdavison Apr 2, 2025
4385990
Adds `Required` parameter for identity attributes
gdavison Apr 2, 2025
4095827
Moves Identity schema to resource registration
gdavison Apr 2, 2025
79cad95
Adds ARN identity to SDK resource generation
gdavison Apr 2, 2025
f37e977
Enables generated Identity for `aws_batch_job_definition`
gdavison Apr 2, 2025
ce3031a
Linting
gdavison Apr 4, 2025
c6989cf
Adds global parameterized identity to SDK resource generation
gdavison Apr 4, 2025
d1f3b5b
Enables generated Identity for `aws_route53_record`
gdavison Apr 4, 2025
a77956c
Enables generated Identity for `aws_iam_role`
gdavison Apr 4, 2025
8291213
Always use generated Identity schema for SDKv2 resource types
gdavison Apr 4, 2025
8b0022f
Resource type `aws_s3_account_public_access_block` is global
gdavison Apr 4, 2025
9138e41
Replaces `resource.ComposeTestCheckFunc` with `resource.ComposeAggreg…
gdavison Apr 4, 2025
83b99e8
Checks that `id` matches `account_id`
gdavison Apr 4, 2025
5b6c215
Adds global singleton identity to SDK resource generation
gdavison Apr 4, 2025
412ef08
Enables generated Identity for `aws_s3_account_public_access_block`
gdavison Apr 4, 2025
7925fbc
Adds regional singleton identity to SDK resource generation
gdavison Apr 4, 2025
a8e871b
Enables generated Identity for `aws_ec2_image_block_public_access`
gdavison Apr 4, 2025
ef56943
Cleanup
gdavison Apr 4, 2025
97a00bf
Adds global parameterized identity for global resources in regional s…
gdavison Apr 4, 2025
dfde5e2
Enables generated Identity for `aws_dx_gateway`
gdavison Apr 4, 2025
e87fda8
Fixes template indenting
gdavison Apr 6, 2025
9d8a117
Adds identity interceptor for Framework
gdavison Apr 6, 2025
5767cc1
Adds ARN identity to Framework resource generation
gdavison Apr 6, 2025
852faf5
Enables generated Identity for `aws_batch_job_queue`
gdavison Apr 6, 2025
397807e
Updates import test notes
gdavison Apr 16, 2025
3840dd9
Adds cross-region Identity test for `aws_batch_job_definition`
gdavison Apr 16, 2025
69904be
Renames test
gdavison Apr 16, 2025
d9891d3
Renames test
gdavison Apr 16, 2025
4546cc3
Renames test
gdavison Apr 16, 2025
14f5cf6
Adds cross-region Identity test for `aws_s3_bucket`
gdavison Apr 16, 2025
8f51314
Updates service package generator to set `RegionOverrideEnabled` to `…
gdavison Apr 16, 2025
1dd5a04
Renames test
gdavison Apr 16, 2025
c348905
`aws_ec2_image_block_public_access` is global
gdavison Apr 16, 2025
2e54a7e
Adds Identity update test for `aws_batch_job_definition`
gdavison Apr 16, 2025
ca2a7d9
Generates parameterized Identity for Framework resources
gdavison Apr 17, 2025
b7552f1
Adds Identity to `aws_cloudfront_key_value_store`
gdavison Apr 17, 2025
e7d68d5
Adds Identity test for `aws_cloudfront_key_value_store`
gdavison Apr 17, 2025
a429c7b
Updates template indentation
gdavison Apr 18, 2025
e3d6bdd
Factors out Identifier Attribute template
gdavison Apr 18, 2025
c30bcc6
Fixes indentation
gdavison Apr 18, 2025
1bc010b
Adds additional Go imports
gdavison Apr 18, 2025
a112a4a
Allows Identity attributes with custom types in Framework
gdavison Apr 24, 2025
45b06eb
Adds Identity to `aws_cloudfrontkeyvaluestore_key`
gdavison Apr 24, 2025
d908535
Adds Identity test for `aws_cloudfrontkeyvaluestore_key`
gdavison Apr 24, 2025
bf2e2ae
Updates `terraform-plugin-testing`
gdavison Apr 24, 2025
23c6276
Adds `resource.ImportBlockWithID` test for `aws_batch_job_queue`
gdavison Apr 24, 2025
050bee6
Adds `resource.ImportBlockWithID` test for `aws_cloudfront_key_value_…
gdavison Apr 24, 2025
858cd36
Adds `resource.ImportBlockWithID` test for `aws_cloudfrontkeyvaluesto…
gdavison Apr 24, 2025
bc4eaf2
Fixes `resource.ImportBlockWithID` test for `aws_dx_gateway`
gdavison Apr 24, 2025
128bac9
Fixes `resource.ImportBlockWithID` test for `aws_iam_role`
gdavison Apr 24, 2025
bae449b
Fixes `resource.ImportBlockWithID` tests for `aws_s3_bucket`
gdavison Apr 24, 2025
97025c2
Fixes `resource.ImportBlockWithID` test for `aws_s3_account_public_ac…
gdavison Apr 24, 2025
1824fd3
Adds `resource.ImportBlockWithID` tests for `aws_route53_record`
gdavison Apr 25, 2025
19183a9
Updates `terraform-plugin-sdk/v2`
gdavison Apr 25, 2025
f4455d6
`schema.ResourceIdentity` now has `SchemaFunc` instead of `Schema`
gdavison Apr 25, 2025
6efbf56
Adds `ImportBlockWithResourceIdentity` support for `aws_dx_gateway`
gdavison Apr 25, 2025
7e06537
Removes unused parameters
gdavison Apr 25, 2025
6c25279
Adds `ImportBlockWithResourceIdentity` support for `aws_iam_role`
gdavison Apr 25, 2025
8206843
`aws_iam_role` does not have an attribute `force_destroy`
gdavison Apr 25, 2025
49a6b70
Adds `ImportBlockWithResourceIdentity` support for `aws_route53_record`
gdavison Apr 26, 2025
8890ce6
Adds `id` checks for `aws_route53_record`
gdavison Apr 26, 2025
79a9140
Renames `set_identifier`
gdavison Apr 26, 2025
be3253b
`aws_route53_record` does not have an attribute `weight`
gdavison Apr 26, 2025
3aa856a
Adds `ImportBlockWithResourceIdentity` support for `aws_s3_bucket`
gdavison Apr 26, 2025
23c28c2
Adds `id` checks for `aws_s3_bucket`
gdavison Apr 26, 2025
4e6402f
Removes redundant setting of `bucket` in Read
gdavison Apr 26, 2025
a5eebc4
Adds `ImportBlockWithResourceIdentity` support for `aws_s3_account_pu…
gdavison Apr 28, 2025
b638516
Adds `id` checks for `aws_batch_job_definition`
gdavison Apr 28, 2025
279f791
Adds `id` checks for `aws_batch_job_queue`
gdavison Apr 28, 2025
893eaaa
Adds `id` checks for `aws_cloudfront_key_value_store`
gdavison Apr 28, 2025
0f86934
Adds `id` checks for `aws_dx_gateway`
gdavison Apr 28, 2025
7ce6672
Adds `id` checks for `aws_iam_role`
gdavison Apr 28, 2025
f3d69c5
Adds `tfstatecheck.ExpectAttributeFormat`
gdavison Apr 28, 2025
6cffe12
Factors out format parsing
gdavison Apr 28, 2025
9db5c3e
Adds `id` checks for `aws_cloudfrontkeyvaluestore_key`
gdavison Apr 28, 2025
5fb44f9
Updates `terraform-plugin-framework`
gdavison Apr 28, 2025
1554bbf
Deprecates `id` attribute
gdavison Apr 28, 2025
c470ec2
Adds `ImportBlockWithResourceIdentity` support for `aws_batch_job_queue`
gdavison Apr 28, 2025
88447fe
Adds `ImportBlockWithResourceIdentity` support for `aws_cloudfront_ke…
gdavison Apr 28, 2025
bdaa79d
Deprecates `id` attribute on `aws_cloudfrontkeyvaluestore_key`
gdavison Apr 28, 2025
3751ea2
Adds custom `ImportState` for `aws_cloudfrontkeyvaluestore_key`
gdavison Apr 28, 2025
2392ef9
Adds `ImportBlockWithResourceIdentity` support for `aws_cloudfrontkey…
gdavison Apr 28, 2025
ed93628
Adds custom `ResourceImporter` to `aws_batch_job_definition`
gdavison Apr 29, 2025
b7f9d7f
Adds `ImportBlockWithID` support for `aws_batch_job_definition`
gdavison Apr 29, 2025
b655378
Adds `ImportPlanChecks` to `aws_batch_job_definition` import tests
gdavison Apr 29, 2025
93152f3
Adds `ImportBlockWithResourceIdentity` support for `aws_batch_job_def…
gdavison Apr 29, 2025
fc5e947
Adds `ImportBlockWithResourceIdentity` support for `aws_batch_job_def…
gdavison Apr 29, 2025
2ca06e3
Mutable identity not currently supported
gdavison Apr 29, 2025
3d604ab
Reverts `Read` and `Update` cases in Identity interceptor
gdavison Apr 29, 2025
67cccfa
Removes ignore `deregister_on_new_revision` from tests for `aws_batch…
gdavison Apr 29, 2025
bc0feff
Removes ignore `deregister_on_new_revision` from generated tests for …
gdavison Apr 29, 2025
70409c8
Adds value checks for `aws_batch_job_queue`
gdavison Apr 29, 2025
68d598b
Adds `MutableIdentity` annotation to exclude Identity schema
gdavison Apr 29, 2025
65998c3
Adds `MutableIdentity` to `aws_batch_job_definition`
gdavison Apr 29, 2025
c16db76
Attribute constants
gdavison Apr 29, 2025
4d325d0
Addresses `ci.directconnect-in-func-name`
gdavison Apr 29, 2025
cbeb06e
Merge branch 'f-region-override-restore-global' into f-resource-identity
gdavison Apr 29, 2025
152f3d1
Extracts `region` from ARN for `aws_batch_job_queue`
gdavison Apr 30, 2025
701444c
Adds cross-region Identity test for `aws_batch_job_queue`
gdavison Apr 30, 2025
857dcc5
Removes redundant `ImportStateIdFunc`
gdavison Apr 30, 2025
e042ff0
Adds value checks for `aws_cloudfront_key_value_store`
gdavison Apr 30, 2025
e368f45
Removes ineffective `ImportPlanChecks`
gdavison Apr 30, 2025
5425a8d
Adds error checking
gdavison Apr 30, 2025
91cfea6
Reverts `region`
gdavison Apr 30, 2025
548ef0d
Adds value checks for `aws_dx_gateway`
gdavison Apr 30, 2025
56fc093
Adds value checks for `aws_iam_role`
gdavison Apr 30, 2025
68f2eb4
Exact value checks
gdavison Apr 30, 2025
8758758
Adds value checks for `aws_route53_record`
gdavison Apr 30, 2025
2cc3b80
Adds `MutableIdentity` to `aws_route53_record`
gdavison Apr 30, 2025
0565d3d
Adds value checks for `aws_s3_bucket`
gdavison Apr 30, 2025
bc69dcd
Adds value checks for `aws_route53_record`
gdavison Apr 30, 2025
0d4e751
Removes function from struct
gdavison Apr 30, 2025
7705472
Adds Importer at provider initialization time for global SDKv2 resour…
gdavison Apr 30, 2025
77a6e98
Removes custom `Importer` from `aws_dx_gateway`
gdavison Apr 30, 2025
52d1b02
Fixes template indentation
gdavison Apr 30, 2025
ac60a45
Adds `@WrappedImport` annotation
gdavison Apr 30, 2025
1f9b25c
Uses `Identity` struct to read Identity attributes during import
gdavison Apr 30, 2025
5b7e825
Adds `@WrappedImport` to `aws_dx_gateway`
gdavison Apr 30, 2025
dda7b7c
Adds `@WrappedImport` to `aws_s3_bucket`
gdavison May 1, 2025
fd4e58d
Sets `account_id` as `id` shadow for Global Singletons
gdavison May 1, 2025
683e626
Adds `@WrappedImport` to `aws_s3_account_public_access_block`
gdavison May 1, 2025
42a9baa
Adds shortcut importer function for SDKv2 Global Singleton
gdavison May 1, 2025
928e945
`aws_route53_record`: Adds `plancheck.ResourceActionReplace` check wh…
gdavison May 1, 2025
2f27987
`aws_route53_record`: Makes `type` `ForceNew`
gdavison May 1, 2025
ccf56f0
Populates `account_id` from provider if not set
gdavison May 1, 2025
338ac81
Validates `account_id` when importing Global Singleton
gdavison May 1, 2025
e48bca4
Removes redundant `IDAttrShadowsAttr` for Global Singleton
gdavison May 1, 2025
e0a285b
Reverts testing check
gdavison May 1, 2025
4ae969e
Adds `account_id` validation to Parameterized Identity importer
gdavison May 2, 2025
4e09b76
Test should not be parallel
gdavison May 2, 2025
32a8b05
Adds `id` check to `aws_s3_account_public_access_block`
gdavison May 2, 2025
45952ab
Adds `@SingletonIdentity` annotation to `aws_rds_certificate`
gdavison May 2, 2025
c64b8f1
Adds basic `id` import tests for `aws_rds_certificate`
gdavison May 2, 2025
d391cf4
Sets `region` from `id`
gdavison May 2, 2025
aa126b0
Adds region override `id` import tests for `aws_rds_certificate`
gdavison May 2, 2025
c39a09c
Adds basic Identity import support for `aws_rds_certificate`
gdavison May 2, 2025
0f36915
Adds cross-region Identity import support for `aws_rds_certificate`
gdavison May 2, 2025
10a9b23
Updates `id` tests for `aws_rds_certificate`
gdavison May 2, 2025
1dac566
Adds shared importer for Regional Singleton
gdavison May 2, 2025
f3b5776
Adds `@WrappedImport` to `aws_rds_certificate`
gdavison May 2, 2025
1e95312
Corrects `aws_rds_certificate` import documentation
gdavison May 2, 2025
3cd46da
Serializes `aws_rds_certificate` Identity tests
gdavison May 2, 2025
c6c58d8
Adds basic `id` import tests for `aws_lb`
gdavison May 2, 2025
38fae72
Makes `testAccCheckLoadBalancerDestroy` region-aware
gdavison May 2, 2025
d206364
Adds `RegionOverride` versions of `ConfigVPCWithSubnets` and dependen…
gdavison May 2, 2025
cdd3f5f
Adds region override `id` import tests for `aws_lb`
gdavison May 2, 2025
d14639a
Adds Identity annotation to `aws_lb`
gdavison May 2, 2025
8aee63e
Updates documentation
gdavison May 2, 2025
7a742cb
Removes unneeded parameter
gdavison May 9, 2025
591323c
Corrects service
gdavison May 27, 2025
d1fb23a
Checks for `region` value
gdavison May 27, 2025
205c0ff
Improves error message
gdavison May 27, 2025
544318a
Handles cross-region import for `aws_lb`
gdavison May 27, 2025
8f6e5d8
Merge branch 'release/6.0.0-beta' into f-resource-identity
gdavison May 27, 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
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,17 @@ require (
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.7.0
github.com/hashicorp/hcl/v2 v2.23.0
github.com/hashicorp/terraform-json v0.24.0
github.com/hashicorp/terraform-plugin-framework v1.14.1
github.com/hashicorp/terraform-json v0.24.1-0.20250314103308-f86d5e36f4ab
github.com/hashicorp/terraform-plugin-framework v1.15.0-beta.1
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0
github.com/hashicorp/terraform-plugin-framework-timeouts v0.5.0
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0
github.com/hashicorp/terraform-plugin-framework-validators v0.17.0
github.com/hashicorp/terraform-plugin-go v0.26.0
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1.0.20250325210248-fa8d1fe4306b
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.18.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1
github.com/hashicorp/terraform-plugin-testing v1.12.0
github.com/hashicorp/terraform-plugin-mux v0.19.0-alpha.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0-beta.1
github.com/hashicorp/terraform-plugin-testing v1.13.0-beta.1
github.com/jmespath/go-jmespath v0.4.0
github.com/mattbaird/jsonpatch v0.0.0-20240118010651-0ba75a80ca38
github.com/mitchellh/copystructure v1.2.0
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,10 @@ github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform-exec v0.23.0 h1:MUiBM1s0CNlRFsCLJuM5wXZrzA3MnPYEsiXmzATMW/I=
github.com/hashicorp/terraform-exec v0.23.0/go.mod h1:mA+qnx1R8eePycfwKkCRk3Wy65mwInvlpAeOwmA7vlY=
github.com/hashicorp/terraform-json v0.24.0 h1:rUiyF+x1kYawXeRth6fKFm/MdfBS6+lW4NbeATsYz8Q=
github.com/hashicorp/terraform-json v0.24.0/go.mod h1:Nfj5ubo9xbu9uiAoZVBsNOjvNKB66Oyrvtit74kC7ow=
github.com/hashicorp/terraform-plugin-framework v1.14.1 h1:jaT1yvU/kEKEsxnbrn4ZHlgcxyIfjvZ41BLdlLk52fY=
github.com/hashicorp/terraform-plugin-framework v1.14.1/go.mod h1:xNUKmvTs6ldbwTuId5euAtg37dTxuyj3LHS3uj7BHQ4=
github.com/hashicorp/terraform-json v0.24.1-0.20250314103308-f86d5e36f4ab h1:5Qpuprk76zkVEdTCtfoPjUc+1AeUxlgkF6sWTr7qLDs=
github.com/hashicorp/terraform-json v0.24.1-0.20250314103308-f86d5e36f4ab/go.mod h1:sMKS8fiRDX4rVlR6EJUMudg1WcanxCMoWwTLkgZP/vc=
github.com/hashicorp/terraform-plugin-framework v1.15.0-beta.1 h1:lX4qacaJc8dqUzEaOALeUW0Gvv0ACs9myvN1WQ4rRgU=
github.com/hashicorp/terraform-plugin-framework v1.15.0-beta.1/go.mod h1:SNnBQzWTh3ydNHBJF8eLVHlm/2gu+RBG508LCfCSVwI=
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 h1:SJXL5FfJJm17554Kpt9jFXngdM6fXbnUnZ6iT2IeiYA=
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0/go.mod h1:p0phD0IYhsu9bR4+6OetVvvH59I6LwjXGnTVEr8ox6E=
github.com/hashicorp/terraform-plugin-framework-timeouts v0.5.0 h1:I/N0g/eLZ1ZkLZXUQ0oRSXa8YG/EF0CEuQP1wXdrzKw=
Expand All @@ -664,14 +664,14 @@ github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0 h1:v3DapR8gsp3E
github.com/hashicorp/terraform-plugin-framework-timetypes v0.5.0/go.mod h1:c3PnGE9pHBDfdEVG9t1S1C9ia5LW+gkFR0CygXlM8ak=
github.com/hashicorp/terraform-plugin-framework-validators v0.17.0 h1:0uYQcqqgW3BMyyve07WJgpKorXST3zkpzvrOnf3mpbg=
github.com/hashicorp/terraform-plugin-framework-validators v0.17.0/go.mod h1:VwdfgE/5Zxm43flraNa0VjcvKQOGVrcO4X8peIri0T0=
github.com/hashicorp/terraform-plugin-go v0.26.0 h1:cuIzCv4qwigug3OS7iKhpGAbZTiypAfFQmw8aE65O2M=
github.com/hashicorp/terraform-plugin-go v0.26.0/go.mod h1:+CXjuLDiFgqR+GcrM5a2E2Kal5t5q2jb0E3D57tTdNY=
github.com/hashicorp/terraform-plugin-mux v0.18.0 h1:7491JFSpWyAe0v9YqBT+kel7mzHAbO5EpxxT0cUL/Ms=
github.com/hashicorp/terraform-plugin-mux v0.18.0/go.mod h1:Ho1g4Rr8qv0qTJlcRKfjjXTIO67LNbDtM6r+zHUNHJQ=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1 h1:WNMsTLkZf/3ydlgsuXePa3jvZFwAJhruxTxP/c1Viuw=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1/go.mod h1:P6o64QS97plG44iFzSM6rAn6VJIC/Sy9a9IkEtl79K4=
github.com/hashicorp/terraform-plugin-testing v1.12.0 h1:tpIe+T5KBkA1EO6aT704SPLedHUo55RenguLHcaSBdI=
github.com/hashicorp/terraform-plugin-testing v1.12.0/go.mod h1:jbDQUkT9XRjAh1Bvyufq+PEH1Xs4RqIdpOQumSgSXBM=
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1.0.20250325210248-fa8d1fe4306b h1:JCAO+OdLztQ6F2bZ8lU93u986UVQl2Y/HNz18/jg3b0=
github.com/hashicorp/terraform-plugin-go v0.27.0-alpha.1.0.20250325210248-fa8d1fe4306b/go.mod h1:HFPb73wivXPZy5wMuE7T3WqFbpIj6R6q1svKnZsnMZo=
github.com/hashicorp/terraform-plugin-mux v0.19.0-alpha.1 h1:WCzSBsp719WKEV/+j+4/o742paM0twYm7B84y7x8pOM=
github.com/hashicorp/terraform-plugin-mux v0.19.0-alpha.1/go.mod h1:iKph9LFBiD4a33AJLgqg7IKSVg2kdlYvx0IRd+ys3Ig=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0-beta.1 h1:Ia0jU/ZLzyfReSg4TMHq6ffYGCNCREzpSMBqswM71a0=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0-beta.1/go.mod h1:fVJWDD6/eNOK0aG55CK5g8vTv3Ph9UD/dZztPPvFDgw=
github.com/hashicorp/terraform-plugin-testing v1.13.0-beta.1 h1:YpdITO9pgpSVSBoxL9DqiOG/2/rUQtcnP6encYAtKd0=
github.com/hashicorp/terraform-plugin-testing v1.13.0-beta.1/go.mod h1:2fJBV6Eim03FqxyaPbPW2qZadDbfD1+yj/tRnDHBjjI=
github.com/hashicorp/terraform-registry-address v0.2.5 h1:2GTftHqmUhVOeuu9CW3kwDkRe4pcBDq0uuK5VJngU1M=
github.com/hashicorp/terraform-registry-address v0.2.5/go.mod h1:PpzXWINwB5kuVS5CA7m1+eO2f1jKb5ZDIxrOPfpnGkg=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
44 changes: 44 additions & 0 deletions internal/acctest/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ func ConfigAvailableAZsNoOptInDefaultExclude() string {
return ConfigAvailableAZsNoOptInExclude("usw2-az4", "usgw1-az2")
}

func ConfigAvailableAZsNoOptInDefaultExclude_RegionOverride(region string) string {
// Exclude usw2-az4 (us-west-2d) as it has limited instance types.
return ConfigAvailableAZsNoOptInExclude_RegionOverride(region, "usw2-az4", "usgw1-az2")
}

func ConfigAvailableAZsNoOptInExclude(excludeZoneIds ...string) string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
Expand All @@ -308,6 +313,22 @@ data "aws_availability_zones" "available" {
`, strings.Join(excludeZoneIds, "\", \""))
}

func ConfigAvailableAZsNoOptInExclude_RegionOverride(region string, excludeZoneIds ...string) string {
return fmt.Sprintf(`
data "aws_availability_zones" "available" {
region = %[2]q

exclude_zone_ids = ["%[1]s"]
state = "available"

filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}
`, strings.Join(excludeZoneIds, "\", \""), region)
}

// AvailableEC2InstanceTypeForAvailabilityZone returns the configuration for a data source that describes
// the first available EC2 instance type offering in the specified availability zone from a list of preferred instance types.
// The first argument is either an Availability Zone name or Terraform configuration reference to one, e.g.
Expand Down Expand Up @@ -565,6 +586,29 @@ resource "aws_subnet" "test" {
)
}

func ConfigVPCWithSubnets_RegionOverride(rName string, subnetCount int, region string) string {
return ConfigCompose(
ConfigAvailableAZsNoOptInDefaultExclude_RegionOverride(region),
fmt.Sprintf(`
resource "aws_vpc" "test" {
region = %[3]q

cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "test" {
count = %[2]d

region = %[3]q

vpc_id = aws_vpc.test.id
availability_zone = data.aws_availability_zones.available.names[count.index]
cidr_block = cidrsubnet(aws_vpc.test.cidr_block, 8, count.index)
}
`, rName, subnetCount, region),
)
}

func ConfigVPCWithSubnetsEnableDNSHostnames(rName string, subnetCount int) string {
return ConfigCompose(
ConfigAvailableAZsNoOptInDefaultExclude(),
Expand Down
42 changes: 42 additions & 0 deletions internal/acctest/knownvalue/account_id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package statecheck

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
)

var _ knownvalue.Check = accountID{}

type accountID struct {
}

// CheckValue determines whether the passed value is of type string, and
// contains a matching sequence of bytes.
func (v accountID) CheckValue(other any) error {
otherVal, ok := other.(string)

if !ok {
return fmt.Errorf("expected string value for AccountID check, got: %T", other)
}

if a, e := otherVal, acctest.AccountID(context.Background()); a != e {
return fmt.Errorf("expected value %s for AccountID check, got: %s", e, a)
}

return nil
}

// String returns the string representation of the value.
func (v accountID) String() string {
return "Who Knows"
}

func AccountID() knownvalue.Check {
return accountID{}
}
60 changes: 60 additions & 0 deletions internal/acctest/statecheck/expect_attribute_format.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package statecheck

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
)

var _ statecheck.StateCheck = expectAttributeFormatCheck{}

type expectAttributeFormatCheck struct {
base Base
attributePath tfjsonpath.Path
format string
}

func (e expectAttributeFormatCheck) CheckState(ctx context.Context, request statecheck.CheckStateRequest, response *statecheck.CheckStateResponse) {
resource, ok := e.base.ResourceFromState(request, response)
if !ok {
return
}

value, err := tfjsonpath.Traverse(resource.AttributeValues, e.attributePath)
if err != nil {
response.Error = err
return
}

otherVal, ok := value.(string)
if !ok {
response.Error = fmt.Errorf("expected string value for ExpectAttributeFormat check, got: %T", value)
return
}

expectedValue, err := populateFromResourceState(e.format, resource)
if err != nil {
response.Error = err
return
}

if otherVal != expectedValue {
response.Error = fmt.Errorf("expected value %s for ExpectAttributeFormat check, got: %s", expectedValue, otherVal)
return
}

return
}

func ExpectAttributeFormat(resourceAddress string, attributePath tfjsonpath.Path, format string) statecheck.StateCheck {
return expectAttributeFormatCheck{
base: NewBase(resourceAddress),
attributePath: attributePath,
format: format,
}
}
109 changes: 109 additions & 0 deletions internal/acctest/statecheck/expect_identity_regional_arn_format.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package statecheck

import (
"context"
"fmt"
"maps"
"slices"

"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
tfknownvalue "github.com/hashicorp/terraform-provider-aws/internal/acctest/knownvalue"
)

var _ statecheck.StateCheck = expectIdentityRegionalARNFormatCheck{}

type expectIdentityRegionalARNFormatCheck struct {
base Base
arnService string
arnFormat string
checkFactory func(service string, arn string) knownvalue.Check
}

func (e expectIdentityRegionalARNFormatCheck) CheckState(ctx context.Context, request statecheck.CheckStateRequest, response *statecheck.CheckStateResponse) {
resource, ok := e.base.ResourceFromState(request, response)
if !ok {
return
}

if resource.IdentitySchemaVersion == nil || len(resource.IdentityValues) == 0 {
response.Error = fmt.Errorf("%s - Identity not found in state. Either the resource does not support identity or the Terraform version running the test does not support identity. (must be v1.12+)", e.base.ResourceAddress())
return
}

if len(resource.IdentityValues) > 1 {
deltaMsg := createDeltaString(resource.IdentityValues, map[string]bool{"arn": true}, "actual identity has extra attribute(s): ")

response.Error = fmt.Errorf("%s - Expected %d attribute(s) in the actual identity object, got %d attribute(s): %s", e.base.ResourceAddress(), 1, len(resource.IdentityValues), deltaMsg)
return
}

attrPath := tfjsonpath.New("arn")
value, err := tfjsonpath.Traverse(resource.AttributeValues, attrPath)
if err != nil {
response.Error = err
return
}

arnString, err := populateFromResourceState(e.arnFormat, resource)
if err != nil {
response.Error = err
return
}

knownCheck := e.checkFactory(e.arnService, arnString)
if err = knownCheck.CheckValue(value); err != nil {
response.Error = fmt.Errorf("checking value for attribute at path: %s.%s, err: %s", e.base.ResourceAddress(), attrPath, err)
return
}
}

func ExpectIdentityRegionalARNFormat(resourceAddress string, arnService, arnFormat string) statecheck.StateCheck {
return expectIdentityRegionalARNFormatCheck{
base: NewBase(resourceAddress),
arnService: arnService,
arnFormat: arnFormat,
checkFactory: func(service string, arn string) knownvalue.Check {
return tfknownvalue.RegionalARNExact(service, arn)
},
}
}

func ExpectIdentityRegionalARNAlternateRegionFormat(resourceAddress string, arnService, arnFormat string) statecheck.StateCheck {
return expectIdentityRegionalARNFormatCheck{
base: NewBase(resourceAddress),
arnService: arnService,
arnFormat: arnFormat,
checkFactory: func(service string, arn string) knownvalue.Check {
return tfknownvalue.RegionalARNAlternateRegionExact(service, arn)
},
}
}

// createDeltaString prints the map keys that are present in mapA and not present in mapB
func createDeltaString[T any, V any](mapA map[string]T, mapB map[string]V, msgPrefix string) string {
deltaMsg := ""

deltaMap := make(map[string]T, len(mapA))
maps.Copy(deltaMap, mapA)
for key := range mapB {
delete(deltaMap, key)
}

deltaKeys := slices.Sorted(maps.Keys(deltaMap))

for i, k := range deltaKeys {
if i == 0 {
deltaMsg += msgPrefix
} else {
deltaMsg += ", "
}
deltaMsg += fmt.Sprintf("%q", k)
}

return deltaMsg
}
Loading
Loading