Skip to content

Latest commit

 

History

History
47 lines (39 loc) · 2.16 KB

README.md

File metadata and controls

47 lines (39 loc) · 2.16 KB

Creating an AWS S3 bucket using CloudFormation

This is an example of using CloudFormation to create bucket to store objects in, a bucket to for the domain and a bucket for logging. It will aslo create the DNS records in Route53 for the website and set up logging.

S3StaticWebsiteCustomDomain.yml contains all the code to create the CloudFormation stacks. The sections are listed below.

  • Parameters - defines root domain
  • Mappings - set in the script to us-east-1
  • Resources
    • SubatomictheoryRootBucket - root bucket containing all the website files
    • SubatomictheoryWWWBucket - configures the website
    • SubatomictheoryLogBucket - logging bucket
    • SubatomictheoryBucketPolicy - policy to allow public read of bucket objects
    • SubatomictheoryDNS - configures Route53 records
  • Outputs - prints out website URLs

To get started run package and deploy the template.

$ aws cloudformation package
$ aws cloudformation deploy --template-file S3StaticWebsiteCustomDomain.yml --stack-name SubatomictheoryStack

To delete the stack and start fresh

$ aws cloudformation delete-stack --stack-name SubatomictheoryStack

To sync S3 folder

aws s3 sync --acl public-read \
    --exclude '*' \
    --include '*.html' \
    --include '*.png' \
    --include '*.css' \
    "/Users/xyz/AWS/S3BucketSite/" s3://subatomictheory.com