Managing a Bucket Website
You can create a bucket and host a static website on it using OUTSCALE Object Storage (OOS).
A static website displays web pages with content primarily coded in HTML that remains consistent for users. Interactive features can still be incorporated to a static website (using JavaScript, for example), but to a lesser degree than dynamic websites that make use of server-side rendering or databases.
Managing a Bucket Website using AWS CLI (s3api)
Creating a Bucket Website
Before you begin: Install and configure AWS CLI and set up your profile. For more information, see Installing and Configuring AWS CLI. |
-
Create an index.html file and an error.html file. Find below examples of content for testing purposes.
The index file (most commonly named
index.html
) is the default returned file when a user accesses the root of your domain. The error file (most commonly namederror.html
) is the file that is returned when an error occurs on your website.Configuration structure for index.html<!doctype html> <html> <head> <title>My Bucket Website</title> </head> <body> <h1>Hi and welcome to my bucket website!</h1> <p>This website is static.</p> </body> </html>
Configuration structure for error.html<!doctype html> <html> <head> <title>404</title> </head> <body> <h1>Oops!</h1> <p>Looks like something went wrong here.</p> </body> </html>
-
Create a configuration file named website.json . Find below a content example for testing purposes.
The website configuration file, usually in JSON format, serves as a blueprint for how your bucket should behave when accessed as a website. You can specify your index and error files as well as other configuration rules. The examples used across this tutorial are kept basic on purpose.
Configuration structure for website.json{ "IndexDocument": { "Suffix": "index.html" }, "ErrorDocument": { "Key": "error.html" } }
-
Upload your objects index.html and error.html in the bucket of your choice, configuring a
public-read
ACL for both. For more information, see Uploading an Object to a Bucket.Request Sample$ aws s3api put-object \ --profile YOUR_PROFILE \ --bucket BUCKET \ --key index.html \ --body path/to/index.html \ --acl public-read \ --endpoint https://oos.eu-west-2.outscale.com
Request Sample$ aws s3api put-object \ --profile YOUR_PROFILE \ --bucket BUCKET \ --key error.html \ --body path/to/error.html \ --acl public-read \ --endpoint https://oos.eu-west-2.outscale.com
-
Create your website with the put-bucket-website command following this syntax:
Request Sample$ aws s3api put-bucket-website \ --profile YOUR_PROFILE \ --bucket BUCKET \ --website-configuration file://path/to/website.json \ --endpoint https://oos.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
bucket
: The bucket in which you want to host your website. -
website-configuration
: The path to the JSON configuration file containing your index and error documents. -
endpoint
: The endpoint corresponding to the Region you want to send the request to.
Your website is created and accessible using the following URL format: https://<BUCKET>.oos-website.<REGION>.outscale.com
-
Getting Information About a Bucket Website
To get information about the website configuration of your bucket, use the get-bucket-website command following this syntax
$ aws s3api get-bucket-website \
--profile YOUR_PROFILE \
--bucket BUCKET \
--endpoint https://oos.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
bucket
: The name of the bucket in which the website is hosted. -
endpoint
: The endpoint corresponding to the Region you want to send the request to.
The get-bucket-website command returns the following elements:
{
"IndexDocument": {
"Suffix": "index.html"
},
"ErrorDocument": {
"Key": "error.html"
}
}
-
IndexDocument
: The name of the index document configured for the website. -
ErrorDocument
: The name of the error document configured for the website.
Deleting a Bucket Website
To delete a bucket website, use the delete-bucket-website command following this syntax:
$ aws s3api delete-bucket-website \
--profile YOUR_PROFILE \
--bucket BUCKET \
--endpoint https://oos.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
bucket
: The name of the bucket in which the website is hosted that you want to delete. -
endpoint
: The endpoint corresponding to the Region you want to send the request to.
Managing a Bucket Website using AWS CLI (s3)
Creating a Bucket Website
Before you begin: Install and configure AWS CLI and set up your profile. For more information, see Installing and Configuring AWS CLI. |
-
Create an index.html file and an error.html file. Find below examples of content for testing purposes.
The index file (most commonly named
index.html
) is the default returned file when a user accesses the root of your domain. The error file (most commonly namederror.html
) is the file that is returned when an error occurs on your website.Configuration structure for index.html<!doctype html> <html> <head> <title>My Bucket Website</title> </head> <body> <h1>Hi and welcome to my bucket website!</h1> <p>This website is static.</p> </body> </html>
Configuration structure for error.html<!doctype html> <html> <head> <title>404</title> </head> <body> <h1>Oops!</h1> <p>Looks like something went wrong here.</p> </body> </html>
-
Upload your objects index.html and error.html in the bucket of your choice, configuring a
public-read
ACL for both. For more information, see Uploading an Object to a Bucket.Request Sample$ aws s3 cp index.html s3://BUCKET/ \ --profile YOUR_PROFILE \ --acl public-read \ --endpoint https://oos.eu-west-2.outscale.com
Request Sample$ aws s3 cp error.html s3://BUCKET/ \ --profile YOUR_PROFILE \ --acl public-read \ --endpoint https://oos.eu-west-2.outscale.com
-
Create your website with the website command following this syntax:
Request Sample$ aws s3 website s3://BUCKET/ \ --profile YOUR_PROFILE \ --index-document index.html \ --error-document error.html \ --endpoint https://oos.eu-west-2.outscale.com
This command contains the following attributes that you need to specify:
-
s3://BUCKET/OBJECT
: The path to the object where your website is hosted. -
(optional)
profile
: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI. -
index-document
: The path to the index file to use for the website. -
error-document
: The path to the error file to use for the website. -
endpoint
: The endpoint corresponding to the Region you want to send the request to.
Your website is created and accessible using the following URL format: https://<BUCKET>.oos-website.<REGION>.outscale.com
-
Related Pages
AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.