This tool is a wrapper around the s3_cmd command line tool to provide easy configuration for creating, maintaining and deleting s3 static websites via a yaml based configuration.
The complexity of using the s3cmd comes when you need to apply configuration to different paths or file types within your static website. This tool aims to reduce that complexity and provide an easier to work with interface.
See the .s3_website_cfg.example for a sample copy of the configuration
used by the tool.
As this tool relies on the s3cmd configuration as it is the interface to AWS. To do this you can use the s3cmd in built configuration helper by executing:
$ s3cmd --configureYou will need to provide your AWS credentials (Access and Secret Key) unless you are using IAM roles from an AWS instance whereby you can leave this configuration blank. All other configuration can be left as default but you may want to set the AWS region to the location where your s3 website will be hosted.
- site
- The directory containing your static website to be uploaded to s3. This
- path needs to be relative to your current location i.e. where you are executing the tool from.
- s3_bucket
- The name of the S3 bucket used by the static website that can be created or
deleted and where the files will be uploaded to. In order to manipulate the
bucket you will need to allow the actions
s3:GetObject,s3:PutObject,s3:DeleteObjectands3:ListBucketon the bucket, Access keys or IAM role. - cloudfront_distribution_id
- The CloudFront distribution to mange. When creating the distribution the id will be displayed for you to add into the configuration.
- cloudfront_cname
- Add a CNAME to the CloudFront distribution to.
- cloudfront_comment
- Add a comment to a CloudFront distribution.
- cloudfront_root_object
- The object to return if no object is specified in the URL.
- cloudfront_no_access_logging
- Turn off access logging for CloudFront requests.
- cache_rules
- A list of rules to determine the configuration of the uploaded files.
Valid configuration is
matchwhich is the files or paths you want wish to effect,maxagethe cache age of the files,gzipfor defining if gzip compression is to be turned on for these files,excludeto remove files or paths from the match andpublicto create sub paths or elements in your website to be public or private. - maxage
- The default cache for files where it is not explicitly defined.
- gzip
- If gzip is to be turn enabled ort disabled if not defined in the match.
- guess_mime_type
- If you want the s3cmd to determine the 'Content-Type' automatically based off the file extension. Left blank or not supplied is the same as 'true'.
- public
- If you want the site to be public or private. Left blank or not supplied is the same as 'true'.
Set the log level:
s3_website -L debug
Set the location of the:
s3_website --s3_cmd_config ~/.s3cfg
Set the location of the website configuration file:
s3_website --s3_website_config ~/static_website.yaml
Display the website information:
s3_website information
Display create the s3 website and bucket:
s3_website create --make_bucket
Display update the contents of the static website in the bucket:
s3_website upload
When defining multiple matches and one includes * ensure you explicitly
exclude other paths to ensure you do not overwrite the changes.
i.e. Where * matches everything and would change the cache and gzip options
for the /css/* matched files.
- match: "/css/*"
maxage: 30 days
gzip: true
- match: "*"
exclude: "/assets"
maxage: 1 hour
gzip: falseThe tool was inspired by s3_deploy_website which provided the basis for the yaml configuration file and required functionality.
MIT.