serverless architecture hosting websites with Lambda and ECR

0

example.com I have an S3 bucket with CloudFront origin using OAI to serve static content. I uploaded a PHP application to ECR. I am still trying to get this all working. The Docker instance runs on my machine but I haven’t got it running in AWS yet. I want to use API gateway to point to a Lambda function that uses the ECS to serve dynamic content. My plan is that once ECS is working to add it to a Lambda and add that to API gateway and then add that to a CloudFront origin which will serve the dynamic content.

example2.com I have another S3 bucket with a CloudFront origin using OAI to serve static content. Another origin points to API gateway which points to a Lambda function written in Python for serving the dynamic content.

Is there a better way to do what I just said? For example, we have an Application Load Balancer. Could I separate everything out and use the ALB to connect everything together and make it look like the API gateway and Cloudfront distributions are all a part of one website?

1 Answer
0

What I understand from your question is that you have a website with both static and dynamic content. I would not use the approach with an API gateway + Lambda function calling an ECS task directly. We did something similar in a project and it quickly became a mess, hard to auto-scale and more. What I would do is create an Application LoadBalancer with the ECS service as target for the ALB. This way you can easy auto-scale the service. Next I would create a CloudFront distribution that serve both the static content and dynamic content, by adding S3 and the ALB as origins. Here you can use a path pattern like /static/ to route requests for static content to the S3 origin.

profile picture
EXPERT
answered a year 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