-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
providers/aws: Add hosted_zone_id and region to attributes #1865
Changes from all commits
d7c9d87
839688d
64d2b49
445f92e
73651e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package aws | ||
|
||
// This list is copied from | ||
// http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints | ||
// It currently cannot be generated from the API json. | ||
var hostedZoneIDsMap = map[string]string{ | ||
"us-east-1": "Z3AQBSTGFYJSTF", | ||
"us-west-2": "Z3BJ6K6RIION7M", | ||
"us-west-1": "Z2F56UZL2M1ACD", | ||
"eu-west-1": "Z1BKCTXD74EZPE", | ||
"central-1": "Z21DNDUVLTQW6Q", | ||
"ap-southeast-1": "Z3O0J2DXBE1FTB", | ||
"ap-southeast-2": "Z1WCIGYICN2BYD", | ||
"ap-northeast-1": "Z2M4EHUR26P7ZW", | ||
"sa-east-1": "Z7KQH4QJS55SO", | ||
"us-gov-west-1": "Z31GFT0UA1I2HV", | ||
} | ||
|
||
// Returns the hosted zone ID for an S3 website endpoint region. This can be | ||
// used as input to the aws_route53_record resource's zone_id argument. | ||
func HostedZoneIDForRegion(region string) string { | ||
return hostedZoneIDsMap[region] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package aws | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestHostedZoneIDForRegion(t *testing.T) { | ||
if r := HostedZoneIDForRegion("us-east-1"); r != "Z3AQBSTGFYJSTF" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Testing a lookup function feels a bit unnecessary, but it's no harm :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was slightly more complex previously because it normalized |
||
t.Fatalf("bad: %s", r) | ||
} | ||
if r := HostedZoneIDForRegion("ap-southeast-2"); r != "Z1WCIGYICN2BYD" { | ||
t.Fatalf("bad: %s", r) | ||
} | ||
|
||
// Bad input should be empty string | ||
if r := HostedZoneIDForRegion("not-a-region"); r != "" { | ||
t.Fatalf("bad: %s", r) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package aws | ||
|
||
import "testing" | ||
|
||
func TestWebsiteEndpointUrl_withoutRegion(t *testing.T) { | ||
u := WebsiteEndpointUrl("buck.et", "") | ||
if u != "buck.et.s3-website-us-east-1.amazonaws.com" { | ||
t.Fatalf("bad: %s", u) | ||
} | ||
} | ||
|
||
func TestWebsiteEndpointUrl_withRegion(t *testing.T) { | ||
u := WebsiteEndpointUrl("buck.et", "us-west-1") | ||
if u != "buck.et.s3-website-us-west-1.amazonaws.com" { | ||
t.Fatalf("bad: %s", u) | ||
} | ||
} |
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.
This is unable to be generated from the API json. Attempted to add to aws-sdk in aws/aws-sdk-go#222, but that was rejected
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.
Can you document here the why (they're looking for a generated means, etc), and maybe a
TODO
so we know that this should ideally go away in the future when aws-sdk-go finally picks it up?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.
Added the docs. Will they pick it up? Doesn't seem likely, unless the API schema somehow exposes it.
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.
@justincampbell I was asking our contact at AWS about this, linking him directly to the related PR at aws-sdk-go.
He was assuring me that if these zone IDs were to change, it would most likely mean changing the domain for S3 websites and/or CloudFront global domain (unlikely to happen in one day, if ever) and more importantly if that ever happens, they would give more than enough time to users to adopt this change.
He also said they may expose it via API at some point, but from my experience, it could mean 6 months, but also 6 years, or even never. There isn't any specific ETA nor guarantee.
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.
I think your comment here is well written, I can't think of a better one.