What are existing:
- S3 bucket 1:
xxx.s3.us-east-1.amazonaws.com
- S3 bucket 2:
yyy.s3.us-east-1.amazonaws.com
- Domain name:
abc.com
What is requiring:
- Using only 1 static domain name:
static.abc.com
- Using only 1 CloudFront distribution to serve both S3 buckets above with prefix (S3 bucket 1 - prefix
admin
and S3 bucket 2 - prefixpublic
) - Eg: What is served with
https://xxx.s3.us-east-1.amazonaws.com/img.jpg
can be served withhttps://static.abc.com/admin/img.jpg
and what is served withhttps://yyy.s3.us-east-1.amazonaws.com/img.png
can be served withhttps://static.abc.com/public/img.png
Idea
- Create a distribution in CloudFront with 2 origins are 2 bucket above
- Create 3 distribution behaviors:
- /admin/* - To Distribution's Origin of S3 Bucket 1
- /public/* - To Distribution's Origin of S3 Bucket 2
- Default(*) - To either Origin of S3 Bucket 1 or Origin of S3 Bucket 2
- Modify 3 distribution behaviors to have function associations to Lambda@Edge function (this will be in another post, but the document for create one here)
Top comments (0)