Object Storage - Website
Functionality overview
The Website functionality allows to expose publicly a bucket as a static website.
A static website only delivers unmodified content, ie. as it is stored.
Typically HTML, CSS and image files or even client-side scripts.
Typical use case: publish a set of documentation.
Access
When Website is enabled for a bucket, the bucket is available as a website with the following endpoint URL:
https://bucket-name.website-region01.cloudavenue.orange-business.com
(replace bucket-name with real value)
The access is strictly read-only and available worldwide.
Configuration steps
- create a bucket
- enable website
- allow public-read on all objects
- upload content
Use case with AWS CLI
(replace bucket-name with real value)
Prerequisite : prepare content
Even if you want to publish individual objects, enabling Website will require an index document.
An index document is a webpage that is returned when nothing specific is requested (sort of a default page).
Request https://bucket-name.website-region01.cloudavenue.orange-business.com and the configured index document will be returned (if the object was uploaded before).
Describing the creation of a entire static website is out of scope here.
Let's focus on the minimum requirement, ie. the index document.
Create an index.html file with the following content:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Static Page</title>
</head>
<body>
<h1>Static page</h1>
A few words.
</body>
</html>
Create a bucket
[root@mytest ~]# aws --endpoint-url https://s3-region01.cloudavenue.orange-business.com s3api create-bucket --bucket bucket-name
{
"Location": "/bucket-name"
}
Enable website for the bucket
Here, object index.html is configured as index document.
[root@mytest ~]# aws --endpoint-url https://s3-region01.cloudavenue.orange-business.com s3 website s3://bucket-name--index-document index.html
Add a bucket policy to allow public read
Create an AllowGetForAllPolicy.json file with the following content:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowGetForAll",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::bucket-name",
"arn:aws:s3:::bucket-name/*"
]
}
]
}
Apply the policy to the bucket:
[root@mytest website]# aws --endpoint-url https://s3-region01.cloudavenue.orange-business.com s3api put-bucket-policy --bucket bucket-name --policy file://AllowGetForAllPolicy.json
Upload content to the bucket
[root@mytest website]# aws --endpoint-url https://s3-region01.cloudavenue.orange-business.com s3api put-object --bucket bucket-name --key index.html --body index.html
{
"ETag": "\"4423a824067897cb9390a034337cab97\""
}