how to automatically deploy a code to ecs in AWS pipeline

0

hi, how to automatically deploy a new code to ECS in AWS pipeline? Source & Build stages in pipeline work well, but Deploy stage cant be executed, it runs for an hour, then finishes with error (timeout). I need to manually stop docker container on EC2 (ECS), after that Deploy stage will work. I m using Free tier, is there any limitation for codepipeline and ecs? Maybe there is a problem with Task Placement.

  • I found where was a problem. Problem was in Dynamic port mapping, i removed a port, and Deploy stage worked. Before it was 80 port for host. How can i configure a port to be 80 always?

3개 답변
0

This is a question that has a lot of valid answers. You could look into letting AWS Copilot deal with with the majority of that for rather simple / straightforward use-cases. You can also look at AppRunner potentially, if your use-case fits what it can cater for.

We use AWS CodePipeline + CodeBuild (and for my personal work make use of free tier as much as I can hehe) to build and deploy. The deployment of services to ECS is done with CloudFormation. The Templates for the ECS tasks / services is generated from docker compose definition files using ECS Compose-X (See examples and labs here). We use the ansible playbook here to setup everything for multi (or single) account deployments, then the rest is up to what kind of services you want to deploy and how to build them. Advantage of ECS Compose-X is that is supports compose syntax so you can run your usual docker-compose up/down commands to do local testing and create additional files specifically for AWS.

We deploy services multiple times a day following this pattern and the devs can focus on writing code instead of dealing with infra.

profile picture
답변함 2년 전
0

There is no restriction in free tier.
Please check the reason for the error in the Deploy stage and the reason for stopping the ECS task.
This will help you solve the problem.

zizi
답변함 2년 전
0

We have similar question. We run ECS on EC2. Our containers are basically just runtime and access the website code on mount volume on the EC2 instances. I use CodeDeploy ECS Blue/Green deployment and it ran successfully to deploy task definition, but it is not able to deploy new website code in the shared mount volume. ECS AppSpec.yml doesn't have copy files to destination sort of thing like EC2/on-premises AppSpec.yml. We have to use Ansible to deploy new website code at this moment, but we can't restart those runtime containers and stop traffic. Is that a way of CodeDeploy Blue/ Green deployment to do so? I also tried CodeDeploy on EC2/ on-premises, but it failed to stop traffic on dynamic ports and it requires code deploy agent to be installed which should not be in ECS CodeDeploy.

답변함 2년 전

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

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

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

관련 콘텐츠