How to Multiple websites on same S3 bucket using Cloudfornt and Lambda@edge?

0

I have use case were I need to host multiple websites in same s3 bucket. The content is seperated inside the S3 bucket via directories. Ex: S3:abc/app1 S3:abc/app2 It will be access via cloudfront URL The cloudfront URL should be able to fetch d7mb****.cloufront.net/app1 d7mb****.cloufront.net/app2

2 Answers
0

Have you looked into this? https://dev.to/unfor19/multiple-static-sites-in-a-single-s3-bucket-served-by-cloudfront-3ako? That should give you a good view on how to host individual sites in different “folders” of a single bucket.

If instead looking into microfrontends, I wrote a series which ends up hosting an app shell and multiple frontends in a single CloudFront distribution with a single S3 bucket. Hope you enjoy it/is helpful: https://levelup.gitconnected.com/a-complete-aws-architecture-for-module-federated-micro-frontends-a0306ba466e3 and https://alatech.medium.com/lerna-module-federation-for-aws-micro-frontends-c26ec6610016

profile picture
EXPERT
answered 8 months ago
0

Hi, thanks for asking this question on re:Post!

You don't necessarily need a Lambda@Edge to rewrite URLs in this case. If the only missing thing is ability to point to multiple index.html files stored under different prefixes on S3 (such as app1, app2), you may use a CloudFront Function to add index.html to request URLs that don’t include a file name. Please let us know if this solves your issue, or provide us with more details about your use case!

AWS
Piotrek
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions