-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
tests/data-source/aws_region: Remove hardcoded us-east-1 handling #16024
Conversation
Reference: #8316 Reference: #15737 Previously in AWS GovCloud (US): ``` === CONT TestAccDataSourceAwsRegion_basic TestAccDataSourceAwsRegion_basic: provider_test.go:196: [{0 error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: InvalidClientTokenId: The security token included in the request is invalid. status code: 403, request id: f02b1c17-7e7d-4e95-ae14-2e02a2f785f4 []}] --- FAIL: TestAccDataSourceAwsRegion_basic (0.54s) === CONT TestAccDataSourceAwsRegion_endpoint TestAccDataSourceAwsRegion_endpoint: provider_test.go:196: [{0 error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: InvalidClientTokenId: The security token included in the request is invalid. status code: 403, request id: 74c054be-32b1-432f-b338-3211315ed76c []}] --- FAIL: TestAccDataSourceAwsRegion_endpoint (0.50s) === CONT TestAccDataSourceAwsRegion_endpointAndName TestAccDataSourceAwsRegion_endpointAndName: provider_test.go:196: [{0 error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: InvalidClientTokenId: The security token included in the request is invalid. status code: 403, request id: 1527b1e9-a329-43f7-b37e-f3a8da479861 []}] --- FAIL: TestAccDataSourceAwsRegion_endpointAndName (0.51s) === CONT TestAccDataSourceAwsRegion_name TestAccDataSourceAwsRegion_name: provider_test.go:196: [{0 error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: InvalidClientTokenId: The security token included in the request is invalid. status code: 403, request id: eef98021-bbe9-46f0-bb2a-4649a0b808dd []}] --- FAIL: TestAccDataSourceAwsRegion_name (0.43s) ``` Output from acceptance testing in AWS Commercial: ``` --- PASS: TestAccDataSourceAwsRegion_basic (13.01s) --- PASS: TestAccDataSourceAwsRegion_name (14.91s) --- PASS: TestAccDataSourceAwsRegion_endpoint (14.92s) --- PASS: TestAccDataSourceAwsRegion_endpointAndName (14.94s) ``` Output from acceptance testing in AWS GovCloud (US): ``` --- PASS: TestAccDataSourceAwsRegion_basic (17.09s) --- PASS: TestAccDataSourceAwsRegion_name (19.02s) --- PASS: TestAccDataSourceAwsRegion_endpoint (19.04s) --- PASS: TestAccDataSourceAwsRegion_endpointAndName (19.05s) ```
So far so good... Commercial:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple questions. Looks great!
GovCloud:
--- PASS: TestAccDataSourceAwsRegion_basic (17.26s)
--- PASS: TestAccDataSourceAwsRegion_name (17.55s)
--- PASS: TestAccDataSourceAwsRegion_endpoint (18.73s)
--- PASS: TestAccDataSourceAwsRegion_endpointAndName (19.09s)
resource.TestCheckResourceAttr(resourceName, "endpoint", "ec2.us-east-1.amazonaws.com"), | ||
resource.TestCheckResourceAttr(resourceName, "name", "us-east-1"), | ||
resource.TestCheckResourceAttr(resourceName, "description", "US East (N. Virginia)"), | ||
resource.TestMatchResourceAttr(dataSourceName, "description", regexp.MustCompile(`^.+$`)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
resource.TestMatchResourceAttr(dataSourceName, "description", regexp.MustCompile(`^.+$`)), | |
resource.TestMatchResourceAttrSet(dataSourceName, "description"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource.TestMatchResourceAttr(dataSourceName, "description", regexp.MustCompile(`^.+$`)),
Ensures that the value has at least one character, while TestCheckResourceAttrSet()
would accept an empty string. We could potentially introduce another testing helper into the SDK, for lack of a better quick name TestCheckResourceAttrNonEmptyString()
, but there are probably some other helpers that should be considered along side anything like that similar in nature to some of our validation functions.
resource.TestCheckResourceAttr(resourceName, "endpoint", endpoint2), | ||
resource.TestCheckResourceAttr(resourceName, "name", name2), | ||
resource.TestCheckResourceAttr(resourceName, "description", description2), | ||
resource.TestMatchResourceAttr(dataSourceName, "description", regexp.MustCompile(`^.+$`)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question.
resource.TestCheckResourceAttr(resourceName, "name", name2), | ||
resource.TestCheckResourceAttr(resourceName, "description", description2), | ||
resource.TestMatchResourceAttr(dataSourceName, "description", regexp.MustCompile(`^.+$`)), | ||
resource.TestMatchResourceAttr(dataSourceName, "endpoint", regexp.MustCompile(fmt.Sprintf("^ec2\\.[^.]+\\.%s$", testAccGetPartitionDNSSuffix()))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
resource.TestMatchResourceAttr(dataSourceName, "endpoint", regexp.MustCompile(fmt.Sprintf("^ec2\\.[^.]+\\.%s$", testAccGetPartitionDNSSuffix()))), | |
rtestAccCheckResourceAttrRegionalHostnameService(dataSourceName, "endpoint", ec2.EndpointsID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration uses the following to allow it to be region-agnostic:
endpoint = "ec2.${tolist(data.aws_regions.test.names)[0]}.${data.aws_partition.test.dns_suffix}"
The first region is not guaranteed to match the region of the test provider instance due to how the DescribeRegions API works and we probably shouldn't be using aws_region
in the testing for aws_region
to try and align things. 😄
This has been released in version 3.15.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Reference: #8316
Reference: #15737
Release note for CHANGELOG:
Much of the functionality is unit tested.
Previously in AWS GovCloud (US):
Output from acceptance testing in AWS Commercial:
Output from acceptance testing in AWS GovCloud (US):