-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update scripts to handle amplify nested stack tagging in parameters.js
- Loading branch information
Showing
8 changed files
with
67 additions
and
97 deletions.
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 |
---|---|---|
@@ -1,10 +1 @@ | ||
[ | ||
{ | ||
"Key": "user:Stack", | ||
"Value": "{project-env}" | ||
}, | ||
{ | ||
"Key": "user:Application", | ||
"Value": "{project-name}" | ||
} | ||
] | ||
[] |
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 |
---|---|---|
@@ -1,72 +1,27 @@ | ||
# Copyright 2023 Amazon Web Services, Inc | ||
# | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
#!/usr/bin/env bash | ||
set -xe | ||
|
||
. "./parameters.sh" | ||
|
||
export AWS_PROFILE=$TEAM_ACCOUNT_PROFILE | ||
|
||
git remote remove origin | ||
git remote add origin codecommit::$REGION://team-idc-app | ||
git remote add team https://github.com/aws-samples/iam-identity-center-team.git | ||
git pull team main | ||
|
||
# Part below will update tag keys and values in amplify/backend/tags.json | ||
IFS=' ' read -ra TAG_ARRAY <<< "$TAGS" | ||
|
||
output="[" | ||
for tag in "${TAG_ARRAY[@]}"; do | ||
IFS='=' read -ra pair <<< "$tag" | ||
key="${pair[0]}" | ||
value="${pair[1]}" | ||
output+="\n {\n \"Key\": \"$key\",\n \"Value\": \"$value\"\n }," | ||
done | ||
|
||
output="${output%,}\n]" | ||
echo "$output" > ../amplify/backend/tags.json | ||
appId=`aws amplify list-apps --output json | jq -r '.apps[] | select(.name=="TEAM-IDC-APP") | .appId' ` | ||
stackName=`aws amplify get-backend-environment --app-id $appId --environment-name main --output json | jq -r '.backendEnvironment | .stackName'` | ||
|
||
if [[ ! -z "$TAGS" ]]; | ||
then | ||
aws cloudformation deploy --region $REGION --template-file template.yml \ | ||
--stack-name TEAM-IDC-APP \ | ||
--parameter-overrides \ | ||
Source=$EMAIL_SOURCE \ | ||
Login=$IDC_LOGIN_URL \ | ||
teamAdminGroup="$TEAM_ADMIN_GROUP" \ | ||
teamAuditGroup="$TEAM_AUDITOR_GROUP" \ | ||
--tags "$TAGS" \ | ||
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM | ||
else | ||
echo "update normal" | ||
aws cloudformation deploy --region $REGION --template-file template.yml \ | ||
--stack-name TEAM-IDC-APP \ | ||
--parameter-overrides \ | ||
Source=$EMAIL_SOURCE \ | ||
Login=$IDC_LOGIN_URL \ | ||
teamAdminGroup="$TEAM_ADMIN_GROUP" \ | ||
teamAuditGroup="$TEAM_AUDITOR_GROUP" \ | ||
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM | ||
fi | ||
aws cloudformation delete-stack --stack-name $stackName | ||
|
||
if git diff-index --quiet HEAD -- "../amplify/backend/tags.json"; then | ||
echo "No changes to amplify/backend/tags.json." | ||
else | ||
git add ../amplify/backend/tags.json | ||
git commit -m "Update tags." | ||
fi | ||
aws cloudformation delete-stack --stack-name TEAM-IDC-APP | ||
|
||
git push origin main | ||
git remote remove team | ||
aws codecommit delete-repository --repository-name team-idc-app |
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
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