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

Add update stack logic for cross-account team role stack #44

Merged
merged 1 commit into from
Jun 2, 2021
Merged
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
31 changes: 31 additions & 0 deletions sdlf-team/scripts/bootstrap_team.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,35 @@ if ! aws cloudformation describe-stacks --stack-name ${STACK_NAME}; then

echo "Waiting for stack to be created ..."
aws cloudformation wait stack-create-complete --stack-name ${STACK_NAME}
else
echo -e "Stack exists, attempting update ..."

set +e
update_output=$( aws cloudformation update-stack \
--stack-name $STACK_NAME \
--parameters \
ParameterKey=pChildAccountId,ParameterValue="${CHILD_ACCOUNT}" \
ParameterKey=pEnvironment,ParameterValue="${ENV}" \
ParameterKey=pTeamName,ParameterValue="${TEAM_NAME}" \
--template-body file://${DIRNAME}/template-team-repos.yaml \
--tags file://${DIRNAME}/../tags.json \
--capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" 2>&1)
status=$?
set -e

echo "$update_output"

if [ $status -ne 0 ] ; then
# Don't fail for no-op update
if [[ $update_output == *"ValidationError"* && $update_output == *"No updates"* ]] ; then
echo -e "\nFinished create/update - no updates to be performed";
exit 0;
else
exit $status
fi
fi

echo "Waiting for stack update to complete ..."
aws cloudformation wait stack-update-complete --stack-name $STACK_NAME
echo "Finished create/update successfully!"
fi