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

Programatically set S3 Bucket Website IndexDocument #42

Open
rjocoleman opened this issue Feb 11, 2013 · 6 comments
Open

Programatically set S3 Bucket Website IndexDocument #42

rjocoleman opened this issue Feb 11, 2013 · 6 comments

Comments

@rjocoleman
Copy link

Is there any way to set IndexDocument for S3 buckets?

http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html

@timkay
Copy link
Owner

timkay commented Feb 13, 2013

I just added support for ?website, so please download the latest version from github.

Here is an example:

echo '<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><RedirectAllRequestsTo><HostName>timkay.com</HostName></RedirectAllRequestsTo></WebsiteConfiguration>' |aws put s3.timkay.com?website

@rjocoleman
Copy link
Author

Thanks @timkay!

I'm not able to get this to work however as expected, is there some way to see verbose output?
I'm getting no output from the command, no errors and the expected change is not made.

echo '<?xml version="1.0" encoding="UTF-8"?>
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<IndexDocument>
<Suffix>index.html</Suffix>
</IndexDocument>
</WebsiteConfiguration>' | aws put my-s3-bucket?website

@timkay
Copy link
Owner

timkay commented Feb 14, 2013

You can add -v or -vv (two v's) to see the actual request sent to S3. I don't think any output is expected from S3... Simply this meta document is written. You can confirm the command worked using "aws get ...?website" 👍

$ aws get s3.timkay.com?website
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
        <RedirectAllRequestsTo>
                <HostName>timkay.com</HostName>
        </RedirectAllRequestsTo>
</WebsiteConfiguration>

It working or not is beyond the scope of the "aws" command. At this point, it's a question entirely about S3 behavior.

@rjocoleman
Copy link
Author

Thanks Tim,

It's "working" and I can see AWS reporting the correct details when I aws get ...?website.

My issue was in my web browser I was accessing http://my-s3-bucket.s3.amazonaws.com/ and, per the docs, it should have been http://my-s3-bucket.s3-website-us-east-1.amazonaws.com/

@timkay
Copy link
Owner

timkay commented Feb 14, 2013

As I understand it, S3 will redirect from the first URL to the second, so either should work. However, it takes some propagation time after creation of the bucket, so the redirection doesn't work immediately. I might be wrong. Please point me to the relevant documentation.

@rjocoleman
Copy link
Author

The trailing slash at the root-level URL is optional. For example, if you configure your website with index.html as the index document, either of the following two URLs will return index.html.

http://example-bucket.s3-website-region.amazonaws.com/
http://example-bucket.s3-website-region.amazonaws.com

http://docs.aws.amazon.com/AmazonS3/latest/dev/IndexDocumentSupport.html

I know this isn't strictly the question being answered above, the best I can see in the docs at this point is there thought.
When setting up Static Website Hosting through the console it specifies the Endpoint.

staticwebsitehosting10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants