Hosting an SPA Using AWS
-
Create the bucket
- Note that you must replace example.com with the name of your domain.
- Your bucket must be named the same as your site name.
-
Create logs.domain.com and www.example.com if you want those
-
In the buckets pane:
- click Properties -> Permissions -> Add Bucket Policy and paste in (changing example.com to your bucket name):
{
"Version":"2012-10-17",
"Statement": [{
"Sid": "Allow Public Access to All Objects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example.com/*"
}
]
}
-
AWS document on how to setup a static website using a custom domain on Cloudfront
-
Set up CNAME records pointing to the address of the new S3 Bucket.
- Change the cname to point to the cloudfront distribution if you want to do so.
Misc
Security:
You need to invalidate cloudfront in order for the updates to s3 to be pushed.