Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECS] [request]: describe-task-definition needs to download an uploadable json including tags #2013

Open
anitakrueger opened this issue Apr 27, 2023 · 3 comments
Labels
ECS Amazon Elastic Container Service Proposed Community submitted issue

Comments

@anitakrueger
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Tell us about your request
What do you want us to build?

In the AWS console for the task definitions, when on the JSON tab, there is a button called "Download AWS CLI input". The downloaded json file looks different from when I run the corresponding AWS cli command to describe the task definition:

aws ecs describe-task-definition --region us-west-2 --profile MyProfile --task-definition my-application 

To be able to deploy a task definition via Github actions, the task definition json needs to look like what is being produced by the UI Button.
Hence the aws ecs describe-task-definition should be able to download the exact same json file.

Which service(s) is this request for?
ECS

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?

Our task definition gets created via terraform including tags. The task definition then ultimately gets updated by a Github workflow when a new build of an image is available. We are following the workflow here: https://github.com/aws-actions/amazon-ecs-deploy-task-definition#task-definition-file (i.e. download the current task definition, render it with the newly built image tag, sanitize it, deploy it again).

However, after a deployment has happened, the task definition being deployed and the one being generated by terraform, differ and hence on the next terraform run, it wants to update the task definition again. This is because the task definition that is being downloaded by aws ecs describe-task-definition comes without tags. Even using the following the json looks different:

        aws ecs describe-task-definition \
          --task-definition ${{ inputs.task_definition }} \
          --include TAGS \
          --query taskDefinition > task-definition.json

Are you currently working around this issue?

Only partly, with a lot of steps in a custom github action to download and "sanitize" the downloaded task definition, but we're still not being able to upload the tags again.

        aws ecs describe-task-definition \
          --task-definition ${{ inputs.task_definition }} \
          --query taskDefinition > task-definition.json

        echo $(jq 'del(. |
        .compatibilities,
        .taskDefinitionArn,
        .requiresAttributes,
        .revision,
        .status,
        .registeredAt,
        .registeredBy)'
        ${{ steps.task-def.outputs.task-definition }}) > clean-task-definition.json

This is still missing the tags though because they are on the same level as the taskDefinition dictionary in the json file.

@anitakrueger anitakrueger added the Proposed Community submitted issue label Apr 27, 2023
@genbit
Copy link

genbit commented May 19, 2023

@anitakrueger would you be able to provide example of terraform code you have that generates TD. So I understand correctly, that you use Terraform to create TD AWS resource, but then run ecs-deploy-task-definition action to trigger deployment (is it update on the service?)

@genbit genbit added the ECS Amazon Elastic Container Service label May 19, 2023
@SP-SuperPoney
Copy link

@genbit : I think the demand is clear enough. If you click on the "Download AWS CLI input" button in the AWS console you get a task JSON file, if you lake the same request with "aws ecs describe-task-definition" you get a different file.

Please provide a command to get the same file or fix the "aws ecs describe-task-definition" to reflect the console button.

@guikcd
Copy link

guikcd commented Jan 30, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ECS Amazon Elastic Container Service Proposed Community submitted issue
Projects
None yet
Development

No branches or pull requests

4 participants