Feedback
Do you have a suggestion to improve this website or boto3?Give us feedback.
An S3 bucket can be configured to host a static website.
Retrieve a bucket’s website configuration by calling the AWS SDK for Pythonget_bucket_website
method.
importboto3# Retrieve the website configurations3=boto3.client('s3')result=s3.get_bucket_website(Bucket='amzn-s3-demo-website-bucket')
A bucket’s website configuration can be set by calling theput_bucket_website
method.
# Define the website configurationwebsite_configuration={'ErrorDocument':{'Key':'error.html'},'IndexDocument':{'Suffix':'index.html'},}# Set the website configurations3=boto3.client('s3')s3.put_bucket_website(Bucket='amzn-s3-demo-website-bucket',WebsiteConfiguration=website_configuration)
A bucket’s website configuration can be deleted by calling thedelete_bucket_website
method.
# Delete the website configurations3=boto3.client('s3')s3.delete_bucket_website(Bucket='amzn-s3-demo-website-bucket')