AWS CDK Deploy ECR Source to ECS Fargate Blue/Green Deployment NestJS Microservice

0

I have a nestjs monorepo micorservice that contains api-gateway and products. My api-gateway is listening on port 5000 and my products microservice is just set up as a microservice. The way I have it set up is that I use RabbitMq messaging to direct to the correct microservice. I am trying to deploy this to aws ecs using the cdk but have some difficulty (and its my first time working with microservices) so not sure where to start. If i understand this correctly I need to do the following:

  1. create an ecs cluster
  2. set up my vpc and listener on port 80 (non-secure)
  3. set up my task definitions ( do i need 1 with both ecr images in it or will i need 1 task definition per microservice, which in my case would be 2? )
  4. create a service ( 1 for each task definition)
  5. how do i set up blue green deployments?
  6. tie it back to my code deploy pipeline

thoughts / suggestions?

1 個回答
1
已接受的答案

Hello,

By API Gateway I guess you mean within your application, not using AWS API Gateway, right?

If you can put your services into a docker-compose file, which helps with local testing and configuration, ECS Compose-X will deal with setting everything up for you: it will create IaC templates (CloudFormation) to deploy everything to AWS (with something as simple as ecs-compose-x up. It will create your ECS Cluster, VPC, the ECS resources, IAM roles, etc. for you. You can also have it deal with other things such as DNS, ELB etc.

Alternatively, you can try Copilot too, but that does not use the docker-compose syntax.

Hope this helps,

profile picture
已回答 1 年前
  • Yea correct. In Nestjs i have 2 "apps" in my monorepo. One api-gateway & products. All my calls go through my api-gateway and using rabbitMq messages it calls the proper microservice (in this case only products). I have a docker-compose file in my project and then Dockerfile in each app. When i do docker-compose up its runs perfectly no issues.

    If this ecs-compose-x up deploys this then perfect ill take a look!

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南