-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from CircleCI-Public/implement-deploy-schedul…
…ed-tasks feat: added deploy-ecs-scheduled-task command
- Loading branch information
Showing
5 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
description: | | ||
Deploy an ECS Scheduled Task Rule after updating a task definition. The update-task-definition command must be run first. | ||
parameters: | ||
rule-name: | ||
description: The name of the scheduled task's rule to update. | ||
type: string | ||
steps: | ||
- run: | ||
name: Deploy rule with updated task definition | ||
environment: | ||
ECS_PARAM_RULE_NAME: <<parameters.rule-name>> | ||
command: <<include(scripts/deploy-ecs-scheduled-task.sh)>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
td_arn=$CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN | ||
|
||
if [ -z "$td_arn" ]; then | ||
echo "Updated task definition not found. Please run update-task-definition command before deploy-ecs-scheduled-task" | ||
exit 1 | ||
fi | ||
|
||
CLI_OUTPUT_FILE=$(mktmp cli-output.json.XXXX) | ||
CLI_INPUT_FILE=$(mktmp cli-input.json.XXXX) | ||
|
||
aws events list-targets-by-rule --rule "$ECS_PARAM_RULE_NAME" --output json > "$CLI_OUTPUT_FILE" | ||
|
||
if < "$CLI_OUTPUT_FILE" jq ' .Targets[] | has("EcsParameters")' | grep "false"; then | ||
echo "Invalid ECS Rule. $ECS_PARAM_RULE_NAME does not contain EcsParameters key. Please create a valid ECS Rule and try again" | ||
exit 1 | ||
fi | ||
|
||
< "$CLI_OUTPUT_FILE" jq --arg td_arn "$td_arn" '.Targets[].EcsParameters.TaskDefinitionArn |= $td_arn' > "$CLI_INPUT_FILE" | ||
aws events put-targets --cli-input-json "$(cat "$CLI_INPUT_FILE")" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters