Scaleway DocumentationStorageObject StorageAPI/CLI
Hosting static websites on a bucket

Jump toUpdate content

Setting up static websites on a bucket with the API

Reviewed on 15 June 2021Published on 17 February 2021

The bucket website feature allows you to host static websites using Scaleway Object Storage.

It is possible to enable and configure the bucket website feature via the AWS-CLI.


Enabling the bucket website feature

To use the bucket website feature, you need to enable it on the bucket or buckets you wish to host your website on.

You can use an API call or the AWS-CLI to enable it using put-bucket-website.

Website JSON grammar

S3 requires you to include index and error pages in your website and to indicate their names in the bucket-website.json file.

Website JSON grammar:


suffix of the HTML index document key, commonly named as “index.html”.
string suffix


error document to return when the requested key access is denied or the key does not exist.


{    "IndexDocument" : {        "Suffix": "index.html"    },    "ErrorDocument": {        "Key": "error.html"    }}

PUT bucket website

This operation enables Bucket Website and sets the basic configuration for the website.

PUT /myBucket?website HTTP/1.1{    "IndexDocument" : {        "Suffix": "index.html"    },    "ErrorDocument": {        "Key": "error.html"    }}

To enable bucket website via the CLI, you can create a file called bucket-website.json with the index and error page names.

{    "IndexDocument" : {        "Suffix": "index.html"    },    "ErrorDocument": {        "Key": "error.html"    }}

And upload it using the following command:

$ aws s3api put-bucket-website --bucket <BUCKET_NAME> --website-configuration file://bucket-website.json

GET bucket website

To visualize the configuration of your website, retrieve it using get-bucket-website.

Sample request

GET /myBucket?website HTTP/1.1

CLI command

$ aws s3api get-bucket-website --bucket <BUCKET_NAME>

DELETE bucket website

This operation deletes the Bucket Website configuration of a specified bucket.


If the operation is successful no output will be returned.

Sample request

DELETE /MyBucket?website HTTP/1.1

CLI command

$ aws s3api delete-bucket-website --bucket myBucket

Configuring your website

After setting up the basic bucket website configuration with put-bucket-website, upload the index.html and the error.html files to your bucket.

You can also upload the rest of the static web page files that make up your website.

Note: If this is your first time uploading objects into a bucket, you can follow the step-by-step on this documentation page.

Configuring access

If you want your website to be accessible, you need to set up a bucket policy.

  1. Set the "Action" as "s3:GetObject" in the bucket-policy.json file,

  2. Specify which resources they can access under "Resource":

          {          "Version": "2012-10-17",          "Id":"MyBucketPolicy",          "Statement": [              {                  "Sid": "DelegateAccess",                  "Effect":"Allow",                  "Principal":"*",                  "Action":[                      "s3:GetObject"                  ],                  "Resource":[                      "<BUCKET_NAME>/*"                  ]              }          ]      }
    • "<BUCKET_NAME>/*" - Grants access to all objects inside a bucket, but not to the bucket itself.
    • "<BUCKET_NAME>/<PREFIX>/*" - Grants access only to objects with the specified prefix inside a bucket, but not to the bucket itself. For example, if you apply a bucket policy that specifies "my_files/movie/*" under Resource, you would grant access to all objects with the movie/ prefix, but not to other objects in my_files/ bucket.
  3. Use PUT Bucket Policy or run the following command to implement the policy via the AWS-CLI:

$ aws s3api put-bucket-policy --bucket <BUCKET_NAME> --policy file://bucket-policy.json

Configuring your URL

You can access your website using the website endpoint of your bucket, generated by s3 under the default format:


Replace <bucket_name> and <bucket_region> accordingly.

Alternatively, you can configure a CNAME Record for your bucket URL, to be able to access the website through a domain name of your choice.

See Also