Skip to content

Deploy a AWS S3 hosted website with a custom Route53 DNS name using CloudFormation

License

Notifications You must be signed in to change notification settings

nickbec10/S3BucketSite

Repository files navigation

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

About

Deploy a AWS S3 hosted website with a custom Route53 DNS name using CloudFormation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published