Skip to content
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

[AWS SDK for Go Migration] Meta Data Sources (Region) Service #39389

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hskiba
Copy link

@hskiba hskiba commented Sep 19, 2024

This resolves problems using region lookup for the newly-launched Malaysia region ap-southeast-5 (see #36224).

This migrates the region data source to AWS SDK v2. In v2, the endpoints package is no longer available. Now, regions need to be queried in the account using the configured client. I chose to use the ec2 client given the current data source supports lookup using the EC2 endpoint. The change in behavior is that if a region is valid but is not available to the account, e.g., cn-north-1 when in the standard partition, the region lookup by name will fail. A number of tests that were successful before because they were static lookups embedded in the SDK are no longer successful when running outside of their partition. I adjusted these tests (TestAccMetaServicePrincipal) to be skipped if not being run from the test case region's partition.

Relations

Relates #36188.
Closes #39224.
Relates #38989.

References

Output from Acceptance Testing

% make testacc TESTS='TestAccMetaRegionDataSource|TestAccMetaServicePrincipal' PKG=meta
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.7 test ./internal/service/meta/... -v -count 1 -parallel 20 -run='TestAccMetaRegionDataSource|TestAccMetaServicePrincipal'  -timeout 360m
=== RUN   TestAccMetaRegionDataSource_FindRegionByEC2Endpoint
=== PAUSE TestAccMetaRegionDataSource_FindRegionByEC2Endpoint
=== RUN   TestAccMetaRegionDataSource_FindRegionByName
=== PAUSE TestAccMetaRegionDataSource_FindRegionByName
=== RUN   TestAccMetaRegionDataSource_basic
=== PAUSE TestAccMetaRegionDataSource_basic
=== RUN   TestAccMetaRegionDataSource_endpoint
=== PAUSE TestAccMetaRegionDataSource_endpoint
=== RUN   TestAccMetaRegionDataSource_endpointAndName
=== PAUSE TestAccMetaRegionDataSource_endpointAndName
=== RUN   TestAccMetaRegionDataSource_name
=== PAUSE TestAccMetaRegionDataSource_name
=== RUN   TestAccMetaServicePrincipal_basic
=== PAUSE TestAccMetaServicePrincipal_basic
=== RUN   TestAccMetaServicePrincipal_MissingService
=== PAUSE TestAccMetaServicePrincipal_MissingService
=== RUN   TestAccMetaServicePrincipal_ByRegion
=== RUN   TestAccMetaServicePrincipal_ByRegion/us-east-1
=== PAUSE TestAccMetaServicePrincipal_ByRegion/us-east-1
=== RUN   TestAccMetaServicePrincipal_ByRegion/cn-north-1
=== PAUSE TestAccMetaServicePrincipal_ByRegion/cn-north-1
=== RUN   TestAccMetaServicePrincipal_ByRegion/us-gov-east-1
=== PAUSE TestAccMetaServicePrincipal_ByRegion/us-gov-east-1
=== RUN   TestAccMetaServicePrincipal_ByRegion/us-iso-east-1
=== PAUSE TestAccMetaServicePrincipal_ByRegion/us-iso-east-1
=== RUN   TestAccMetaServicePrincipal_ByRegion/us-isob-east-1
=== PAUSE TestAccMetaServicePrincipal_ByRegion/us-isob-east-1
=== RUN   TestAccMetaServicePrincipal_ByRegion/eu-isoe-west-1
=== PAUSE TestAccMetaServicePrincipal_ByRegion/eu-isoe-west-1
=== CONT  TestAccMetaServicePrincipal_ByRegion/us-east-1
=== CONT  TestAccMetaServicePrincipal_ByRegion/us-iso-east-1
=== CONT  TestAccMetaServicePrincipal_ByRegion/eu-isoe-west-1
=== CONT  TestAccMetaServicePrincipal_ByRegion/us-gov-east-1
=== CONT  TestAccMetaServicePrincipal_ByRegion/cn-north-1
=== CONT  TestAccMetaServicePrincipal_ByRegion/us-isob-east-1
=== NAME  TestAccMetaServicePrincipal_ByRegion/us-gov-east-1
    service_principal_data_source_test.go:66: skipping tests; current partition (aws) does not equal aws-us-gov
=== NAME  TestAccMetaServicePrincipal_ByRegion/us-iso-east-1
    service_principal_data_source_test.go:66: skipping tests; current partition (aws) does not equal aws-iso
=== NAME  TestAccMetaServicePrincipal_ByRegion/cn-north-1
    service_principal_data_source_test.go:66: skipping tests; current partition (aws) does not equal aws-cn
=== NAME  TestAccMetaServicePrincipal_ByRegion/us-isob-east-1
    service_principal_data_source_test.go:66: skipping tests; current partition (aws) does not equal aws-iso-b
=== NAME  TestAccMetaServicePrincipal_ByRegion/eu-isoe-west-1
    service_principal_data_source_test.go:66: skipping tests; current partition (aws) does not equal aws-iso-e
--- PASS: TestAccMetaServicePrincipal_ByRegion (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_ByRegion/us-gov-east-1 (0.83s)
    --- SKIP: TestAccMetaServicePrincipal_ByRegion/us-iso-east-1 (0.83s)
    --- SKIP: TestAccMetaServicePrincipal_ByRegion/cn-north-1 (0.83s)
    --- SKIP: TestAccMetaServicePrincipal_ByRegion/us-isob-east-1 (0.83s)
    --- SKIP: TestAccMetaServicePrincipal_ByRegion/eu-isoe-west-1 (0.83s)
    --- PASS: TestAccMetaServicePrincipal_ByRegion/us-east-1 (13.40s)
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/cloudhsm
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/cloudhsm
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/config
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/config
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/logs
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/logs
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/workspaces
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/workspaces
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/dms
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/dms
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/logs
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/logs
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/codedeploy
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/codedeploy
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/elasticmapreduce
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/elasticmapreduce
=== RUN   TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/logs
=== PAUSE TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/logs
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/cloudhsm
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/logs
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/workspaces
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/logs
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/config
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/cloudhsm
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-iso
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/logs
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-iso-b
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/workspaces
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-iso
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/elasticmapreduce
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/codedeploy
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/dms
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/codedeploy
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-cn
=== CONT  TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/logs
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/config
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-iso
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/elasticmapreduce
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-cn
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/logs
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-cn
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/logs
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-iso
=== NAME  TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/dms
    service_principal_data_source_test.go:140: skipping tests; current partition (aws) does not equal aws-iso-b
--- PASS: TestAccMetaServicePrincipal_UniqueForServiceInRegion (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/cloudhsm (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/logs (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/workspaces (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/codedeploy (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/config (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/elasticmapreduce (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/cn-north-1/logs (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-iso-east-1/logs (0.00s)
    --- SKIP: TestAccMetaServicePrincipal_UniqueForServiceInRegion/us-isob-east-1/dms (0.00s)
=== CONT  TestAccMetaRegionDataSource_FindRegionByEC2Endpoint
=== CONT  TestAccMetaServicePrincipal_MissingService
=== CONT  TestAccMetaServicePrincipal_basic
=== CONT  TestAccMetaRegionDataSource_basic
=== CONT  TestAccMetaRegionDataSource_name
=== CONT  TestAccMetaRegionDataSource_endpoint
=== CONT  TestAccMetaRegionDataSource_FindRegionByName
=== CONT  TestAccMetaRegionDataSource_endpointAndName
--- PASS: TestAccMetaServicePrincipal_MissingService (1.37s)
--- PASS: TestAccMetaRegionDataSource_FindRegionByName (1.96s)
--- PASS: TestAccMetaRegionDataSource_FindRegionByEC2Endpoint (2.12s)
--- PASS: TestAccMetaServicePrincipal_basic (14.66s)
--- PASS: TestAccMetaRegionDataSource_basic (14.67s)
--- PASS: TestAccMetaRegionDataSource_endpointAndName (15.96s)
--- PASS: TestAccMetaRegionDataSource_endpoint (16.06s)
--- PASS: TestAccMetaRegionDataSource_name (17.38s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/meta	35.735s

Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/meta Issues and PRs that pertain to the meta service. needs-triage Waiting for first response or review from a maintainer. labels Sep 19, 2024
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome @hskiba 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTOR guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@hskiba hskiba marked this pull request as ready for review September 19, 2024 10:28
@hskiba hskiba requested a review from a team as a code owner September 19, 2024 10:28
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Sep 19, 2024
@ewbankkit ewbankkit self-assigned this Sep 19, 2024
@github-actions github-actions bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Sep 19, 2024
@hskiba hskiba force-pushed the td-migrate_region_data_source_sdkv2 branch from 64c13a6 to 07827d3 Compare September 20, 2024 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/meta Issues and PRs that pertain to the meta service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ap-southeast-5
2 participants