As far if you follow this blog's posts, here mostly posts are related to cloud tasks assigned to me as an requirement, you can think as one of the industry standard requirements too.
In this blog post, we will see how we can achieve the above scenario that is One CloudFront domain to host multiple S3 buckets as origin.
Let's follow the steps as follow.
Create 3 different S3 buckets as per above architecture diagram.
As per the architecture diagram, create respective directories to match the URI path that is
- http://d233xxyxzzz.cloudfront.net/web1 --> s3-web1-bucket --> Create web1 directory inside s3-web1-bucket/
- htttp://d233xxyxzzz.cloudfront.net/web2 --> s3-web2-bucket --> Create web2 directory inside s3-web2-bucket/
Dump 3 individual index.html files, that resembles to be an identifier as content served from that specific bucket.
- index.html path for s3-web-bucket -- s3-web-bucket/index.html
- index.html path for s3-web1-bucket -- s3-web-bucket/web1/index.html
- index.html path for s3-web2-bucket -- s3-web-bucket/web2/index.html
This is how my three different index.html looks like.
Note : Default root object to index.html, else we have to append index.html manually every time after /
Now here comes the fun, we have our CloudFront URL in active state and thus according to our architecture this is what we are expecting overall.
Create Origins for S3 buckets.
Let's add other two more origin, which are the two other remaining s3 buckets.
Origin Configuration for S3 bucket "s3-web1-bucket"
Origin Configuration for S3 bucket "s3-web2-bucket"
Create Behaviors for the above origins.
So far, we have added all the s3 buckets as origin, now let's create the behavior which is path aka URI based routing.
Behavior 1 - /web1 routes to s3-web1-bucket
Behavior 2 - /web2 routes to s3-web2-bucket
No comments:
Post a Comment