Pushing to ECS with updated image tag

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?

Looking at the docs at Amazon ECS/Fargate · Codefresh | Docs I think you need to pass 2 arguments (image name AND image tag)

If that doesn’t work, then please open an issue with us so that our support team can investigate

Thanks Kostis. I tried passing both the name and the tag, and that didn’t change anything.

I did open a ticket, and they informed me that the step I was using (ecs-deploy) doesn’t actually support passing the image tag. The solution, as you pointed out, was to use a freestyle step as described in the ECS/Fargate example using the codefreshplugins/cf-deploy-ecs image.

I’ve filed a bug about this step’s image tag problem, and I hope you can fix it soon. I can’t actaully figure out how this step can be of any use in a build pipeline, if there’s no way to point the step at the image that has just been built!