Skip to content
Latchkey

aws ecs register-task-definition: New ECS Revision in CI

Register a new task definition revision pointing at a freshly built image.

aws ecs register-task-definition creates a new immutable revision of a task definition, typically with an updated container image tag. In CI you render a JSON file with the new image, register it, capture the revision, then call update-service.

Common flags

  • --cli-input-json file://taskdef.json - supply the full task definition from a file
  • --family - the task definition family name
  • --container-definitions - inline container array (alternative to a file)
  • --query "taskDefinition.revision" - capture the new revision number

Example in CI

Register a rendered task definition and capture the revision.

shell
aws ecs register-task-definition --cli-input-json file://taskdef.json --query "taskDefinition.revision" --output text

Common errors in CI

  • An error occurred (ClientException) - invalid or missing required task definition fields
  • Error parsing parameter cli-input-json - malformed JSON or wrong file:// path
  • An error occurred (AccessDeniedException) - role lacks ecs:RegisterTaskDefinition or iam:PassRole

Key takeaways

  • register-task-definition creates a new immutable revision from JSON.
  • It commonly needs iam:PassRole for the task execution role.
  • Capture taskDefinition.revision to feed into ecs update-service.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →