I want my pipeline to fetch code from GitHub, create a Docker image, push it to ECR with a tag, and then deploy this new image on ECS (Fargate). It seems like this should be the simplest thing in the world, but I cannot figure out how to do it.
The problem right now is that the task definition isn’t being modified to use the new tag created in the build step. I would expect the ecs-deploy
step to take an image argument but it does not. I have found the code for cfecs-update
which says I should be able to pass an --image-tag
argument to the script, so I have tried this:
deploy_staging:
title: "Deploy to ECS staging environment"
type: ecs-deploy
commands:
- cfecs-update --image-tag ${{CF_SHORT_REVISION}} us-east-2 my-cluster my-service
arguments:
aws-region: '${{AWS_DEFAULT_REGION}}'
region: '${{AWS_DEFAULT_REGION}}'
AWS_ACCESS_KEY_ID: '${{AWS_ACCESS_KEY_ID}}'
AWS_SECRET_ACCESS_KEY: '${{AWS_SECRET_ACCESS_KEY}}'
cluster_name: "my-cluster"
service_name: "my-service"
But when this runs, I see this in the console:
Updating Service: cluster = my-cluster , service = my-service
{ 'deploy_timeout': 900,
'image_name': None,
'image_tag': None,
'max_failed': 2,
'region_name': 'us-east-2',
'wait': True}
So it looks like the image_tag isn’t actually being passed along. And indeed, the newest version of the task definition uses the same image URL as the old version.
How can I specify the image tag which Codefresh should deploy using ECS?