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

provider: Automatically validate new regions from AWS SDK #3159

Merged
merged 2 commits into from
Jan 30, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 27, 2018

Reference: https://docs.aws.amazon.com/sdk-for-go/api/aws/endpoints/

This version keeps the stricter == matching for ValidateRegion(), but we could loosen it to the below, which would also turn on regexp matching.

if _, isValidRegion := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), c.Region); isValidRegion {
  return nil
}

@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Jan 27, 2018
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jan 27, 2018
@bflad bflad added the provider Pertains to the provider itself, rather than any interaction with AWS. label Jan 29, 2018
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

I like the idea, although manual maintenance kind of forced us to support the region fully (i.e. lookup all the account IDs etc.) instead of semi-automatically providing basic support.

Overall I'm happy for you to merge this, but not before addressing this https://github.com/terraform-providers/terraform-provider-aws/blob/c7e748cff0995061b1ceacc444d9e92ece430d77/aws/hosted_zones.go#L28

Otherwise there's chance we'll expose people to crash once Amazon introduces new region and we bump SDK and forget to lookup the ID and add it to the map.

@bflad
Copy link
Contributor Author

bflad commented Jan 29, 2018

It turns out that code is actually "okay" (at least from crash standpoint): https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/hosted_zones_test.go#L15

The type is map[string]string and string literals have a zero value of "". We just see crashes other places due to usage of map[string]interface{} which has nil zero value

@radeksimko
Copy link
Member

Right, so it won't crash 👌

You just made me think that maybe for some lists, like this one in particular we should actually silently fail to allow folks use the S3 bucket resource, but I still think such failure should be logged as WARN or something.

https://github.com/terraform-providers/terraform-provider-aws/blob/e221786c28ba9dfb0b7794df4031a1feaa03309b/aws/resource_aws_s3_bucket.go#L1035-L1039

https://github.com/terraform-providers/terraform-provider-aws/blob/5f3605b9807c6ba4e57a4cdd6faa9bd787a6dac4/aws/data_source_aws_s3_bucket.go#L94-L97

@bflad
Copy link
Contributor Author

bflad commented Jan 29, 2018

I think there are some nuances to consider. I think cn-northwest-1 for example supports S3 buckets but not S3 website hosting. As long as we "best effort" support some functionality that AWS is inconsistently offering across regions then I'll apply any changes you'd like

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jan 29, 2018
@bflad
Copy link
Contributor Author

bflad commented Jan 29, 2018

Changed the S3 website hosted zone ID function signature to HostedZoneIDForRegion(region string) (string, error) and it'll now log WARN messages when missing instead of setting it to "". Please let me know if you'd like anything else adjusted. 😄

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

👍

@bflad bflad merged commit f10106a into master Jan 30, 2018
@bflad bflad deleted the f-provider-automatic-regions branch January 30, 2018 12:47
bflad added a commit that referenced this pull request Jan 30, 2018
@bflad bflad added this to the v1.9.0 milestone Jan 30, 2018
@bflad
Copy link
Contributor Author

bflad commented Feb 9, 2018

This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 8, 2020

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 Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants