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개 답변
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
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠