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

d/Adds a url_suffix attribute to data_source_aws_partition #5602

Merged
merged 3 commits into from
Aug 7, 2019
Merged

d/Adds a url_suffix attribute to data_source_aws_partition #5602

merged 3 commits into from
Aug 7, 2019

Conversation

lorengordon
Copy link
Contributor

Fixes #1960

Changes proposed in this pull request:

  • Adds a urlsuffix attribute to the AWSClient struct
  • Infers the urlsuffix value from the STS endpoint associated with the provider region
  • Uses the new attribute to add a url_suffix attribute to data_source_aws_partition

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSPartition_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestAccAWSPartition_basic -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSPartition_basic
--- PASS: TestAccAWSPartition_basic (4.34s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       4.379s

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Aug 18, 2018
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Aug 19, 2018
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. provider Pertains to the provider itself, rather than any interaction with AWS. labels Aug 20, 2018
@aeschright aeschright requested a review from a team June 25, 2019 21:26
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @lorengordon 👋 Thanks for submitting this and apologies for the long silence here. I left some initial feedback below. Please let us know if you have any questions or do not have time to implement these items.

aws/config.go Outdated Show resolved Hide resolved
aws/data_source_aws_partition.go Outdated Show resolved Hide resolved
website/docs/d/partition.html.markdown Outdated Show resolved Hide resolved
@@ -458,6 +459,20 @@ func (c *Config) Client() (interface{}, error) {
}
}

// Infer URL Suffix from STS Endpoint
resolver := endpoints.DefaultResolver()
endpoint, err := resolver.EndpointFor(endpoints.StatesServiceID, client.region)
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment notes inferring this information from the STS endpoint, however its using the states service.

That said, the AWS Go SDK documentation lists the XXXServiceID constants as deprecated: https://docs.aws.amazon.com/sdk-for-go/api/aws/endpoints/#pkg-constants

Deprecated: Use client package's EndpointsID value instead of these ServiceIDs. These IDs are not maintained, and are out of date.

This should be swapped out according to that deprecation.

Ideally though, we should fetch this information directly from the AWS Go SDK endpoints information first, then only fallback to parsing an endpoint should that fail since endpoint hostnames may not always follow a consistent implementation. I have submitted an upstream feature request in the AWS to directly provide the DNS suffix information, which can help prevent us from hardcoding these cases in the future: aws/aws-sdk-go#2710

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one I'm not sure when I'll have time to research and figure out the alternative. If anyone wants to take it, please be my guest!

@bflad bflad self-assigned this Jul 23, 2019
@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Jul 23, 2019
@ghost ghost added documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jul 23, 2019
@bflad bflad added this to the v2.23.0 milestone Aug 7, 2019
@bflad
Copy link
Contributor

bflad commented Aug 7, 2019

Thanks so much for your patience, @lorengordon -- I was able to get the DNS suffix information visible from the AWS Go SDK (aws/aws-sdk-go#2711), rebase this PR, default to using that new information, and add verifying acceptance testing when setting the region to AWS Commercial, GovCloud (US), and China 👍

--- PASS: TestAccAWSPartition_basic (6.97s)

--- PASS: TestAccAWSProvider_Region_AwsCommercial (2.88s)
--- PASS: TestAccAWSProvider_Region_AwsGovCloudUs (2.93s)
--- PASS: TestAccAWSProvider_Region_AwsChina (2.98s)

@bflad bflad merged commit bf023e6 into hashicorp:master Aug 7, 2019
bflad added a commit that referenced this pull request Aug 7, 2019
@lorengordon
Copy link
Contributor Author

Brilliant! Thanks @bflad!

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Aug 7, 2019
@lorengordon lorengordon deleted the url-suffix branch August 7, 2019 14:44
@ghost
Copy link

ghost commented Aug 7, 2019

This has been released in version 2.23.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!

@ghost
Copy link

ghost commented Nov 2, 2019

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!

@ghost ghost locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. provider Pertains to the provider itself, rather than any interaction with AWS. size/M Managed by automation to categorize the size of a PR. 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.

AWS missing "pseudo" parameters
2 participants