Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support code deploy config override #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/commands/update-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ parameters:
Only effective when the deployment-controller parameter value is "CODE_DEPLOY".
type: string
default: ''
codedeploy-deployment-config-name:
description: >
The name of the group's deployment config.
Only effective when the deployment-controller parameter value is "CODE_DEPLOY".
type: string
default: ''
codedeploy-load-balanced-container-name:
description: >
The name of the container to be load-balanced via AWS CodeDeploy.
Expand Down Expand Up @@ -169,6 +175,7 @@ steps:
DEPLOYMENT_CONTROLLER: <<parameters.deployment-controller>>
ECS_PARAM_CD_APP_NAME: <<parameters.codedeploy-application-name>>
ECS_PARAM_CD_DEPLOY_GROUP_NAME: <<parameters.codedeploy-deployment-group-name>>
ECS_PARAM_CD_DEPLOY_CONFIG_NAME: <<parameters.codedeploy-deployment-config-name>>
ECS_PARAM_CD_LOAD_BALANCED_CONTAINER_NAME: <<parameters.codedeploy-load-balanced-container-name>>
ECS_PARAM_CD_LOAD_BALANCED_CONTAINER_PORT: <<parameters.codedeploy-load-balanced-container-port>>
ECS_PARAM_VERIFY_REV_DEPLOY: <<parameters.verify-revision-is-deployed>>
Expand Down
7 changes: 7 additions & 0 deletions src/jobs/deploy-service-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ parameters:
"CODE_DEPLOY".
type: string
default: ''
codedeploy-deployment-config-name:
description: >
The name of the group's deployment config.
Only effective when the deployment-controller parameter value is "CODE_DEPLOY".
type: string
default: ''
codedeploy-load-balanced-container-name:
description: >
The name of the container to be load-balanced via AWS CodeDeploy.
Expand Down Expand Up @@ -184,6 +190,7 @@ steps:
deployment-controller: << parameters.deployment-controller >>
codedeploy-application-name: << parameters.codedeploy-application-name >>
codedeploy-deployment-group-name: << parameters.codedeploy-deployment-group-name >>
codedeploy-deployment-config-name: << parameters.codedeploy-deployment-config-name >>
codedeploy-load-balanced-container-name: << parameters.codedeploy-load-balanced-container-name >>
codedeploy-load-balanced-container-port: << parameters.codedeploy-load-balanced-container-port >>
container-image-name-updates: << parameters.container-image-name-updates >>
Expand Down
20 changes: 15 additions & 5 deletions src/scripts/update-bluegreen-service-via-task-def.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,36 @@ set -o noglob
ECS_PARAM_CD_APP_NAME=$(eval echo "$ECS_PARAM_CD_APP_NAME")
ECS_PARAM_CD_DEPLOY_GROUP_NAME=$(eval echo "$ECS_PARAM_CD_DEPLOY_GROUP_NAME")
ECS_PARAM_CD_LOAD_BALANCED_CONTAINER_NAME=$(eval echo "$ECS_PARAM_CD_LOAD_BALANCED_CONTAINER_NAME")
ECS_PARAM_CD_DEPLOY_CONFIG_NAME=$(eval echo "$ECS_PARAM_CD_DEPLOY_CONFIG_NAME")

if [ -z $ECS_PARAM_CD_DEPLOY_CONFIG_NAME ]
then
DEPLOYMENT_CONFIG_NAME_ARG=""
else
DEPLOYMENT_CONFIG_NAME_ARG="--deployment-config-name $ECS_DEPLOYMENT_CONFIG_NAME"
fi


DEPLOYED_REVISION=$CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN

DEPLOYED_REVISION="${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}"

DEPLOYMENT_ID=$(aws deploy create-deployment \
--application-name "$ECS_PARAM_CD_APP_NAME" \
--deployment-group-name "$ECS_PARAM_CD_DEPLOY_GROUP_NAME" \
--application-name $ECS_PARAM_CD_APP_NAME \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to keep the " so it's properly evaluated

--deployment-group-name $ECS_PARAM_CD_DEPLOY_GROUP_NAME \
$DEPLOYMENT_CONFIG_NAME_ARG \
--revision "{\"revisionType\": \"AppSpecContent\", \"appSpecContent\": {\"content\": \"{\\\"version\\\": 1, \\\"Resources\\\": [{\\\"TargetService\\\": {\\\"Type\\\": \\\"AWS::ECS::Service\\\", \\\"Properties\\\": {\\\"TaskDefinition\\\": \\\"${CCI_ORB_AWS_ECS_REGISTERED_TASK_DFN}\\\", \\\"LoadBalancerInfo\\\": {\\\"ContainerName\\\": \\\"$ECS_PARAM_CD_LOAD_BALANCED_CONTAINER_NAME\\\", \\\"ContainerPort\\\": $ECS_PARAM_CD_LOAD_BALANCED_CONTAINER_PORT}}}}]}\"}}" \
--query deploymentId \
--output text)
echo "Created CodeDeploy deployment: $DEPLOYMENT_ID"

if [ "$ECS_PARAM_VERIFY_REV_DEPLOY" == "1" ]; then
echo "Waiting for deployment to succeed."
if $(aws deploy wait deployment-successful --deployment-id "${DEPLOYMENT_ID}"); then
if $(aws deploy wait deployment-successful --deployment-id $DEPLOYMENT_ID); then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come you're removing the extra evaluation?

echo "Deployment succeeded."
else
echo "Deployment failed."
exit 1
fi
fi

echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> "$BASH_ENV"
echo "export CCI_ORB_AWS_ECS_DEPLOYED_REVISION='${DEPLOYED_REVISION}'" >> "$BASH_ENV"