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 Answers
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
answered a year ago
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
answered a year ago
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.

answered 4 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