Skip to content

Commit

Permalink
feat: implement run-task-output parameter
Browse files Browse the repository at this point in the history
feat: implement run-task-output parameter
  • Loading branch information
brivu authored Jun 10, 2022
2 parents 8fe4598 + cc14369 commit 9c88f23
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ workflows:
task-definition: "${AWS_RESOURCE_NAME_PREFIX_EC2}-sleep360"
launch-type: "EC2"
awsvpc: false
run-task-output: "run-task-output.json"
overrides: '{"containerOverrides":[{"name": "${INTERPOLATION_TEST}", "memory": 512}]}'
context: [CPE_ORBS_AWS]
- tear-down-run-task-test:
Expand Down
6 changes: 6 additions & 0 deletions src/commands/run-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ parameters:
description: AWS profile name to be configured.
type: string
default: ''
run-task-output:
description: |
Specifies a local json file to save the output logs from the aws ecs run-task command. Use tools like JQ to read and parse this information such as "task-arns" and "task-ids"
type: string
default: ''
steps:
- run:
name: Run Task
Expand All @@ -137,3 +142,4 @@ steps:
ECS_PARAM_PROPAGATE_TAGS: <<parameters.propagate-tags>>
ECS_PARAM_CAPACITY_PROVIDER_STRATEGY: <<parameters.capacity-provider-strategy>>
ECS_PARAM_PROFILE_NAME: <<parameters.profile-name>>
ECS_PARAM_RUN_TASK_OUTPUT: <<parameters.run-task-output>>
6 changes: 6 additions & 0 deletions src/jobs/run-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ parameters:
If a `capacity-provider-strategy` is specified, the `launch-type` parameter must be set to an empty string.
type: string
default: ""
run-task-output:
description: |
Specifies a local json file to save the output logs from the aws ecs run-task command. Use tools like JQ to read and parse this information such as "task-arns" and "task-ids"
type: string
default: ''
steps:
- aws-cli/setup:
aws-access-key-id: << parameters.aws-access-key-id >>
Expand All @@ -175,3 +180,4 @@ steps:
propagate-tags: << parameters.propagate-tags >>
capacity-provider-strategy: << parameters.capacity-provider-strategy >>
profile-name: << parameters.profile-name >>
run-task-output: <<parameters.run-task-output>>
6 changes: 5 additions & 1 deletion src/scripts/run-task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ set -- "$@" --task-definition "$ECS_PARAM_TASK_DEF"
echo "Setting --cluster"
set -- "$@" --cluster "$ECS_PARAM_CLUSTER_NAME"

aws ecs run-task "$@"
if [ -n "${ECS_PARAM_RUN_TASK_OUTPUT}" ]; then
aws ecs run-task "$@" | tee "${ECS_PARAM_RUN_TASK_OUTPUT}"
else
aws ecs run-task "$@"
fi

0 comments on commit 9c88f23

Please sign in to comment.