You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the capability to wait until the end of an ECS task execution. Additionally, add the option to use the exit code as a way to track success or failure of the step.
The expected behaviors should be similar to the verify_revision_is_deployed parameter in update_service command. The difference with a service is that we know this task will end, and there is a different way to request the task status.
Default behavior (current one): no wait. Similar to fire-and-forget.
Examples:
description: Start the run of an ECS task on Fargate.usage:
version: 2.1orbs:
aws-ecs: circleci/aws-ecs@6.0.0aws-cli: circleci/aws-cli@5.1.0jobs:
run_task:
docker:
- image: cimg/python:3.10steps:
- aws-cli/setup:
profile_name: "OIDC-USER"role_arn: "arn:aws:iam::123456789012:role/VALID_OIDC_ECS_ROLE"
- aws-ecs/run_task:
cluster: cluster1region: us-east-1task_definition: myappsubnet_ids: '$SUBNET_ONE, $SUBNET_TWO'security_group_ids: $SECURITY_GROUP_IDSwait_for_task_stopped: trueworkflows:
run_task:
jobs:
- run_task
Possible implementation using bash:
#!/bin/sh
AWS_PROFILE=default
ECS_CLUSTER=cluster_name
CONTAINER_NAME=migrate
# Run task and get its arn# NOTE: many of the necessary cli inputs have been omitted here
TASK_ARN=$(aws ecs run-task \ --cluster $ECS_CLUSTER \ --query 'tasks[].taskArn' \ --output text)# Wait for ecs task to stop
aws ecs wait tasks-stopped \
--cluster $ECS_CLUSTER \
--tasks $TASK_ARN# Get exit code
TASK_EXIT_CODE=$(aws ecs describe-tasks \ --cluster $ECS_CLUSTER \ --tasks $TASK_ARN \ --query "tasks[0].containers[?name=='$CONTAINER_NAME'].exitCode" \ --output text)echo"The $TASK_ARN ran in ECS cluster $ECS_CLUSTER and its $CONTAINER_NAME returned exit code $TASK_EXIT_CODE"# exit with the same codeexit$TASK_EXIT_CODE
Warning
From the AWS ecs wait tasks-stopped command documentation:
it will poll every 6 seconds until a successful state has been reached. This will exit with a return code of 255 after 100 failed checks.
The AWS CLI do not offer parameters to control the poll interval nor the number of poll attempts.
Describe Request:
Add the capability to wait until the end of an ECS task execution. Additionally, add the option to use the exit code as a way to track success or failure of the step.
The expected behaviors should be similar to the
verify_revision_is_deployed
parameter inupdate_service
command. The difference with a service is that we know this task will end, and there is a different way to request the task status.Default behavior (current one): no wait. Similar to fire-and-forget.
Examples:
Possible implementation using bash:
Warning
From the AWS
ecs wait tasks-stopped
command documentation:The AWS CLI do not offer parameters to control the poll interval nor the number of poll attempts.
Supporting Documentation Links:
The text was updated successfully, but these errors were encountered: