aws-s3-website
Deploy static website to AWS S3
TLDR
Configure a bucket as a static website
Configure an error page for the website
SYNOPSIS
aws-s3-website
aws-s3-website
PARAMETERS
Specifies the action to perform. Common commands include deploy (uploads files and configures bucket), configure (generates a configuration file), setup-bucket (configures S3 bucket for hosting), upload (only uploads files), invalidate (invalidates CloudFront cache), setup-cloudfront (creates/updates CloudFront distribution).
--config
Specifies the path to a JSON configuration file (e.g., s3website.json) that defines bucket settings, paths, and other deployment parameters. This is often the primary way to manage project-specific settings.
--bucket
The name of the S3 bucket where the website will be hosted. Required if not specified in the configuration file.
--region
The AWS region where the S3 bucket is located (e.g., us-east-1). Required if not specified in the configuration file.
--index-document
The default index document for the website (e.g., index.html).
--error-document
The default error document for the website (e.g., 404.html).
--delete
When deploying, deletes files from the S3 bucket that are not present in the local source directory. Use with caution.
--dryrun
Performs a simulated run, showing what actions would be taken without actually making any changes to the S3 bucket or CloudFront.
--profile
Uses a specific AWS credential profile configured in your ~/.aws/credentials file.
--no-invalidate
Prevents the command from invalidating the CloudFront cache after deployment, which can save costs but may result in stale content being served.
--gzip
Enables Gzip compression for text-based files (e.g., .html, .css, .js) before uploading them to S3, improving load times.
--confirm
Bypasses confirmation prompts for actions like deletion or major changes.
DESCRIPTION
The aws-s3-website command-line tool, typically a Python-based utility, streamlines the often complex process of deploying static websites to Amazon S3. It automates numerous steps that would otherwise require manual configuration in the AWS console or intricate scripting with the AWS CLI. Its core functionality includes configuring an S3 bucket for website hosting, setting up appropriate bucket policies (e.g., public read access), defining CORS rules, handling index and error documents (like index.html and 404.html), and managing content uploads.
Beyond basic deployment, it can also integrate with AWS CloudFront to serve content via a CDN, offering features like cache invalidation and Gzip compression for optimized delivery. The tool aims to provide a quick and efficient way for developers to host their static sites, single-page applications, or documentation sites directly from an S3 bucket, abstracting away much of the underlying AWS infrastructure complexity.
CAVEATS
The aws-s3-website command is not a standard Linux command; it is a third-party Python utility. Therefore, it requires Python and pip to be installed on your system. Additionally, proper AWS credentials (via AWS CLI configuration or environment variables) must be set up and possess sufficient IAM permissions to manage S3 buckets and, if applicable, CloudFront distributions. This tool is primarily designed for static website hosting and does not support server-side logic or dynamic content generation.
INSTALLATION
Since aws-s3-website is a Python package, it can be installed using pip:
pip install aws-s3-website
CONFIGURATION FILE
The tool often relies on a s3website.json or .s3website file in your project root. This file contains all necessary parameters for deployment, such as the bucket name, region, source directory, index/error documents, and CloudFront settings, allowing for repeatable deployments.
HISTORY
The aws-s3-website tool emerged from the need to simplify the often verbose and multi-step process of hosting static content on Amazon S3 using the AWS CLI. Developed as an open-source Python project, its goal was to provide a more declarative and streamlined approach, abstracting away the intricacies of S3 bucket policies, CORS, and CloudFront integration. It gained popularity among developers looking for a quick and reliable way to deploy static websites and single-page applications without deep AWS console navigation or complex scripting.