Skip to content

Commit

Permalink
Merge pull request #313 from rekejarikre/main
Browse files Browse the repository at this point in the history
Add support for external repositories due to CodeCommit Deprecation
  • Loading branch information
tawoyinfa authored Oct 25, 2024
2 parents cb364ba + 4d09771 commit 30e741e
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"snsNotificationTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"KmsMasterKeyId": "alias/aws/sns",
"TopicName": {
"Fn::Join": [
"",
Expand Down
166 changes: 115 additions & 51 deletions deployment/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,61 +25,125 @@ fi

cd ..

aws codecommit create-repository --region $REGION --repository-name team-idc-app --repository-description "Temporary Elevated Access Management (TEAM) Application"
git remote remove origin
git remote add origin codecommit::$REGION://team-idc-app
git push origin main
if [ -z "$SECRET_NAME" ]; then
aws codecommit create-repository --region $REGION --repository-name team-idc-app --repository-description "Temporary Elevated Access Management (TEAM) Application"
git remote remove origin
git remote add origin codecommit::$REGION://team-idc-app
git push origin main

cd ./deployment
if [[ ! -z "$TAGS" ]]; then
if [[ ! -z "$UI_DOMAIN" ]]; then
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
tags="$TAGS" \
teamAccount="$TEAM_ACCOUNT" \
customAmplifyDomain="$UI_DOMAIN" \
--tags $TAGS \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
cd ./deployment
if [[ ! -z "$TAGS" ]]; then
if [[ ! -z "$UI_DOMAIN" ]]; then
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
tags="$TAGS" \
teamAccount="$TEAM_ACCOUNT" \
customAmplifyDomain="$UI_DOMAIN" \
--tags $TAGS \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
else
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
tags="$TAGS" \
teamAccount="$TEAM_ACCOUNT" \
--tags $TAGS \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
fi
else
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
tags="$TAGS" \
teamAccount="$TEAM_ACCOUNT" \
--tags $TAGS \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
if [[ ! -z "$UI_DOMAIN" ]]; then
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
teamAccount="$TEAM_ACCOUNT" \
tags="$TAGS" \
customAmplifyDomain="$UI_DOMAIN" \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
else
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
teamAccount="$TEAM_ACCOUNT" \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
fi
fi
else
if [[ ! -z "$UI_DOMAIN" ]]; then
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
teamAccount="$TEAM_ACCOUNT" \
tags="$TAGS" \
customAmplifyDomain="$UI_DOMAIN" \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
cd ./deployment
if [[ ! -z "$TAGS" ]]; then
if [[ ! -z "$UI_DOMAIN" ]]; then
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
tags="$TAGS" \
teamAccount="$TEAM_ACCOUNT" \
customAmplifyDomain="$UI_DOMAIN" \
customRepository="Yes" \
customRepositorySecretName="$SECRET_NAME" \
--tags $TAGS \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
else
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
tags="$TAGS" \
teamAccount="$TEAM_ACCOUNT" \
customRepository="Yes" \
customRepositorySecretName="$SECRET_NAME" \
--tags $TAGS \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
fi
else
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
teamAccount="$TEAM_ACCOUNT" \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
if [[ ! -z "$UI_DOMAIN" ]]; then
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
teamAccount="$TEAM_ACCOUNT" \
tags="$TAGS" \
customAmplifyDomain="$UI_DOMAIN" \
customRepository="Yes" \
customRepositorySecretName="$SECRET_NAME" \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
else
aws cloudformation deploy --region $REGION --template-file template.yml \
--stack-name TEAM-IDC-APP \
--parameter-overrides \
Login=$IDC_LOGIN_URL \
CloudTrailAuditLogs=$CLOUDTRAIL_AUDIT_LOGS \
teamAdminGroup="$TEAM_ADMIN_GROUP" \
teamAuditGroup="$TEAM_AUDITOR_GROUP" \
teamAccount="$TEAM_ACCOUNT" \
customRepository="Yes" \
customRepositorySecretName="$SECRET_NAME" \
--no-fail-on-empty-changeset --capabilities CAPABILITY_NAMED_IAM
fi
fi
fi
4 changes: 3 additions & 1 deletion deployment/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ aws cloudformation delete-stack --region $REGION --stack-name $stackName

aws cloudformation delete-stack --region $REGION --stack-name TEAM-IDC-APP

aws codecommit delete-repository --region $REGION \--repository-name team-idc-app
if [ -z "$SECRET_NAME" ]; then
aws codecommit delete-repository --region $REGION \--repository-name team-idc-app
fi
5 changes: 4 additions & 1 deletion deployment/parameters-mgmt-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ TEAM_ADMIN_GROUP="team_admin_group_name"
TEAM_AUDITOR_GROUP="team_auditor_group_name"
TAGS="project=iam-identity-center-team environment=prod"
CLOUDTRAIL_AUDIT_LOGS=read_write
UI_DOMAIN=portal.teamtest.online
SECRET_NAME=TEAM-IDC-APP
# Uncomment the next line only if you have a custom domain
# UI_DOMAIN=portal.teamtest.online

3 changes: 3 additions & 0 deletions deployment/parameters-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ TEAM_ADMIN_GROUP="team_admin_group_name"
TEAM_AUDITOR_GROUP="team_auditor_group_name"
TAGS="project=iam-identity-center-team environment=prod"
CLOUDTRAIL_AUDIT_LOGS=arn:aws:cloudtrail:us-east-1:123456789101:eventdatastore/e646f20d-7959-4682-be84-6c5b8a37cf15
SECRET_NAME=TEAM-IDC-APP

# Uncomment the next line only if you have a custom domain
# UI_DOMAIN=portal.teamtest.online


23 changes: 22 additions & 1 deletion deployment/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,21 @@ Parameters:
Type: String
Description: Custom domain for the TEAM application
Default: ""
customRepository:
Type: String
Description: Use a custom repository for the TEAM application?
AllowedValues:
- 'Yes'
- 'No'
Default: 'No'
customRepositorySecretName:
Type: String
Description: Name of the secret in AWS Secrets Manager
Default: ''

Conditions:
IsEmptyCloudTrailAuditLogs: !Equals [!Ref CloudTrailAuditLogs, ""]
UseExternalRepo: !Equals [!Ref customRepository, 'Yes']

Resources:
TriggerAmplifyBuild:
Expand Down Expand Up @@ -63,7 +75,16 @@ Resources:
Type: "AWS::Amplify::App"
Properties:
Name: TEAM-IDC-APP
Repository: !Sub https://git-codecommit.${AWS::Region}.amazonaws.com/v1/repos/team-idc-app
Repository: !If
- UseExternalRepo
- !Sub >-
{{resolve:secretsmanager:${customRepositorySecretName}:SecretString:url}}
- !Sub https://git-codecommit.${AWS::Region}.amazonaws.com/v1/repos/team-idc-app
AccessToken: !If
- UseExternalRepo
- !Sub >-
{{resolve:secretsmanager:${customRepositorySecretName}:SecretString:AccessToken}}
- !Ref 'AWS::NoValue'
Description: Temporary Elevated Access Management Application
CustomRules:
- Source: /<*>
Expand Down
Loading

0 comments on commit 30e741e

Please sign in to comment.