Skip to content

CICD-265 · AWS ECS deployment ​

Encyclopedia · Cloud infrastructure integration · All snippets

Previous · CICD-264 · Next · CICD-266

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites provider CLI, scoped CI identity, test environment and provider configuration for named resource.
  • Platforms github-actions, cloud-cli.
  • Parameters ECS_CLUSTER, ECS_SERVICE, TASK_DEF_ARN.

2. Copy the snippet ​

bash
aws ecs update-service --cluster "${ECS_CLUSTER:?}" --service "${ECS_SERVICE:?}" --task-definition "${TASK_DEF_ARN:?}" >/dev/null
aws ecs wait services-stable --cluster "$ECS_CLUSTER" --services "$ECS_SERVICE"
aws ecs describe-services --cluster "$ECS_CLUSTER" --services "$ECS_SERVICE" --query 'services[0].taskDefinition' --output text | grep -Fx "$TASK_DEF_ARN"

3. How it works ​

The update requests a specific registered task definition. The subsequent describe confirms the stable service is running the intended revision after any automatic recovery.

A stable ECS service can still have rolled back to another revision.

flowchart TD
  N1["Requested task definition"]
  N2["Update ECS service"]
  N1 --> N2
  N3["Wait for stability"]
  N2 --> N3
  N4{"Actual definition matches"}
  N3 --> N4
  N5["Candidate confirmed"]
  N4 -->|Yes| N5
  N6["Fail the release check"]
  N4 -->|No| N6

4. Verify the result ​

Verify the intended task definition after waiting because a circuit-breaker rollback can also become stable.

Validation syntax-validated (Bash parse). Status definitions.