-
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
Add website_domain for S3 buckets. #2210
Conversation
Anyone comments on this? |
Thanks for this, I bumped into this issue yesterday too. |
@@ -244,6 +251,9 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error { | |||
if err := d.Set("website_endpoint", endpoint); err != nil { | |||
return err | |||
} | |||
if err := d.Set("website_domain", strings.TrimPrefix(endpoint, fmt.Sprintf("%s.", d.Id()))); err != nil { |
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.
Instead of trimming a string we build elsewhere, why not build the domain first and use that domain in website_endpoint
?
Considering we have to call the s3conn.GetBucketLocation
(i.e. we need the bucket name to get the domain), I would consider creating a new type
, e.g.
type S3Website struct {
Endpoint, Domain string
}
and then change websiteEndpoint(s3conn *s3.S3, d *schema.ResourceData) (string, error)
to website(s3conn *s3.S3, d *schema.ResourceData) (S3Website, error)
.
That should be efficient enough since we only need to call the function once and get both domain+endpoint.
Hey @johnrengelman are you planning on incorporating Radek's feedback, or do you want to leave as is? |
I'll incorporate the feedback...Just need to find some time to do it. So unless you are looking for stuff to do, I should have this updated in the next couple days. |
excellent, thanks for following up! |
@catsby @radeksimko - I finally got a around to incorporating those comments into this. |
@@ -67,3 +67,4 @@ The following attributes are exported: | |||
* `hosted_zone_id` - The [Route 53 Hosted Zone ID](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints) for this bucket's region. | |||
* `region` - The AWS region this bucket resides in. | |||
* `website_endpoint` - The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. | |||
* `website_domain` - The domain of the website endpoint, if teh bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. |
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.
if teh bucket
😄
Hey @johnrengelman sorry for dragging my feet here; just 2 nitpicks and things looks good otherwise |
@catsby cleanup this up based on your comments and rebased. |
bucket = "website.notexample.com" | ||
acl = "public-read" | ||
website { | ||
index_document = index.html |
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.
index.html
needs to be in quotes, or the test fails to parse the config
Hey @johnrengelman sorry to drag you on, but I tried running the test and beyond the parse issue, I got this result:
|
@catsby just pushed a fix for that. Looks like a copy paste error on my part. |
Passing now, thanks! |
Add website_domain for S3 buckets.
Merged – sorry for all the run around, I appreciate the extra work 😄 |
No worries. That's how open source should work. |
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Solution for #2208