CI/CD for AWS ECS
Build and push a Docker image to AWS ECR and trigger an AWS ECS deployment.
Use template →1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
env: ROLE_ARN: arn:aws:iam::$AWS_ACCOUNT_ID:role/my-role IMAGE_NAME: $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/my-repo CLUSTER: my-cluster SERVICE: my-service AWS_PAGER: "" # Disable AWS CLI pagination in CI steps: - label: ":ecr: Push image" key: "push-image" command: | docker build --platform=linux/amd64 -t $IMAGE_NAME:latest . docker push $IMAGE_NAME:latest plugins: - aws-assume-role-with-web-identity#v1.0.0: role_arn: $ROLE_ARN - ecr#v2.8.0: login: true - label: ":ecs: Deploy service" depends_on: "push-image" timeout_in_minutes: 5 command: | aws ecs update-service --cluster $CLUSTER --service $SERVICE --force-new-deployment aws ecs wait services-stable --cluster $CLUSTER --service $SERVICE plugins: - aws-assume-role-with-web-identity#v1.0.0: role_arn: $ROLE_ARN
- Use cases
- Continuous deployment, Continuous integration
- Platforms
- AWS
CI/CD for AWS ECS
Build and push a Docker image to AWS ECR and trigger an AWS ECS deployment.
Use template →CI/CD for AWS ECS
This templates gives you a continuous deployment (CD) pipeline that builds and deploys the latest version of an AWS ECR hosted Docker image to AWS ECS.
At a glance:
- For Docker applications
- Requires AWS CLI
- Uses the AWS Assume Role plugin to access AWS credentials
- Uses ECR for hosting images
- Deploys to AWS ECS
How it works
This template:
- Builds a Docker image
- Assumes an AWS role using the AWS Assume Role with Web Identity plugin.
- Pushes a tagged Docker image to an AWS ECR registry.
- Deploys an AWS ECS service with the latest image.
- Waits for the AWS ECS service to stabilize.
Next steps
After you select Use template, you’ll:
- Connect the Git repository with your project.
- Using an AWS IAM role with the appropriate ECR and ECS policies, replace the placeholder
ROLE_ARN
in the pipeline definition. - Replace the placeholder
IMAGE_NAME
,SERVICE
andCLUSTER
in the pipeline definition to match your project. - Configure the compute—run locally, on-premises, or in the cloud.
- Run the pipeline.
You can then play around with the pipeline settings. For example, run the pipeline locally while you iterate on the definition or set a schedule to trigger a nightly build.
If you need help, please check our documentation, raise an issue , or reach out to support.