Skip to content

Commit aee4ef3

Browse files
author
Hoseong-Seo
committed
SBT v5.0 applied and source S3 bucket name fixed
1 parent 8b71955 commit aee4ef3

File tree

6 files changed

+22
-19
lines changed

6 files changed

+22
-19
lines changed

scripts/cleanup.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if ! confirm; then
2121
fi
2222

2323
export REGION=$(aws ec2 describe-availability-zones --output text --query 'AvailabilityZones[0].[RegionName]')
24+
export ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
2425

2526
echo "$(date) emptying out buckets..."
2627
for i in $(aws s3 ls | awk '{print $3}' | grep -E "^tenant-update-stack-*|^controlplane-stack-*|^core-appplane-*|^saas-reference-architecture-*"); do
@@ -38,7 +39,7 @@ cd ../server
3839
npm install
3940

4041
export CDK_PARAM_SYSTEM_ADMIN_EMAIL="NA"
41-
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$REGION"
42+
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$ACCOUNT_ID-$REGION"
4243
export CDK_PARAM_COMMIT_ID="NA"
4344
export CDK_PARAM_REG_API_GATEWAY_URL="NA"
4445
export CDK_PARAM_EVENT_BUS_ARN=arn:aws:service:::resource
@@ -60,7 +61,7 @@ versions=$(aws s3api list-object-versions --bucket $CDK_PARAM_S3_BUCKET_NAME --o
6061
if [ "$versions" -gt 0 ]; then
6162
aws s3api list-object-versions --bucket $CDK_PARAM_S3_BUCKET_NAME --output json \
6263
| jq '{"Objects": [.Versions[] | {Key: .Key, VersionId: .VersionId}]}' > $TEMP_FILE
63-
aws s3api delete-objects --bucket $CDK_PARAM_S3_BUCKET_NAME --delete file://$TEMP_FILE
64+
aws s3api delete-objects --bucket $CDK_PARAM_S3_BUCKET_NAME --delete file://$TEMP_FILE --no-cli-pager
6465
fi
6566

6667
# Deleting object markers
@@ -71,7 +72,7 @@ delete_markers=$(aws s3api list-object-versions --bucket $CDK_PARAM_S3_BUCKET_NA
7172
if [ "$delete_markers" -gt 0 ]; then
7273
aws s3api list-object-versions --bucket $CDK_PARAM_S3_BUCKET_NAME --output json \
7374
| jq '{"Objects": [.DeleteMarkers[] | {Key: .Key, VersionId: .VersionId}]}' > $TEMP_FILE
74-
aws s3api delete-objects --bucket $CDK_PARAM_S3_BUCKET_NAME --delete file://$TEMP_FILE
75+
aws s3api delete-objects --bucket $CDK_PARAM_S3_BUCKET_NAME --delete file://$TEMP_FILE --no-cli-pager
7576
fi
7677

7778

scripts/deprovision-tenant.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if [[ $TIER == "PREMIUM" || $TIER == "ADVANCED" ]]; then
8686
STACK_NAME=$(sed -e 's/^"//' -e 's/"$//' <<<$STACK_NAME)
8787
echo "Stack name from $TENANT_STACK_MAPPING_TABLE is $STACK_NAME"
8888
# Copy to S3 Bucket
89-
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$REGION"
89+
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$ACCOUNT_ID-$REGION"
9090
export CDK_SOURCE_NAME="source.zip"
9191
CDK_PARAM_COMMIT_ID=$(aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs[?OutputKey=='S3SourceVersion'].OutputValue" --output text)
9292

scripts/install.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ if [[ -z "$CDK_PARAM_SYSTEM_ADMIN_EMAIL" ]]; then
88
fi
99

1010
REGION=$(aws ec2 describe-availability-zones --output text --query 'AvailabilityZones[0].[RegionName]') # Region setting
11-
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$REGION"
11+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
12+
13+
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$ACCOUNT_ID-$REGION"
1214

1315
# Create S3 Bucket for provision source.
1416

1517
if aws s3api head-bucket --bucket $CDK_PARAM_S3_BUCKET_NAME 2>/dev/null; then
1618
echo "Bucket $CDK_PARAM_S3_BUCKET_NAME already exists."
1719
else
18-
echo "Bucket $CDK_PARAM_S3_BUCKET_NAME does not exist. Creating a new bucket in $REGION region"
20+
echo "Bucket $CDK_PARAM_S3_BUCKET_NAME does not exist. Creating a new bucket in $REGION region in $ACCOUNT_ID"
1921

2022
if [ "$REGION" == "us-east-1" ]; then
2123
aws s3api create-bucket --bucket $CDK_PARAM_S3_BUCKET_NAME
@@ -46,7 +48,7 @@ fi
4648
echo "Bucket exists: $CDK_PARAM_S3_BUCKET_NAME"
4749

4850
cd ../
49-
zip -r source.zip . -x ".git/*" -x "**/node_modules/*" -x "**/cdk.out/*" -x "**/.aws-sam/*"
51+
zip -rq source.zip . -x ".git/*" -x "**/node_modules/*" -x "**/cdk.out/*" -x "**/.aws-sam/*"
5052
export CDK_PARAM_COMMIT_ID=$(aws s3api put-object --bucket "${CDK_PARAM_S3_BUCKET_NAME}" --key "source.zip" --body "./source.zip" --output text)
5153

5254
rm source.zip
@@ -74,19 +76,19 @@ SERVICES=$(aws ecs list-services --cluster $CDK_BASIC_CLUSTER --query 'serviceAr
7476
for SERVICE in $SERVICES; do
7577
SERVICE_NAME=$(echo $SERVICE | rev | cut -d '/' -f 1 | rev)
7678

79+
echo -n "==== Service Connect Disable: "
7780
aws ecs update-service \
7881
--cluster $CDK_BASIC_CLUSTER \
7982
--service $SERVICE_NAME \
8083
--service-connect-configuration 'enabled=false' \
81-
--no-cli-pager
84+
--no-cli-pager --query 'service.serviceArn' --output text
8285

83-
echo "Service Connect disabled for service: $SERVICE_NAME"
8486
done
8587

8688
npm install
8789

8890
npx cdk bootstrap
89-
npx cdk deploy --all --require-approval never
91+
npx cdk deploy --all --require-approval=never
9092

9193
# Get SaaS application url
9294
ADMIN_SITE_URL=$(aws cloudformation describe-stacks --stack-name controlplane-stack --query "Stacks[0].Outputs[?OutputKey=='adminSiteUrl'].OutputValue" --output text)

scripts/provision-tenant.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export REGION=$(aws ec2 describe-availability-zones --output text --query 'Avail
1616
export ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
1717

1818
# Download from the ecs reference solution Bucket
19-
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$REGION"
19+
export CDK_PARAM_S3_BUCKET_NAME="saas-reference-architecture-ecs-$ACCOUNT_ID-$REGION"
2020
export CDK_SOURCE_NAME="source.zip"
2121

2222
VERSIONS=$(aws s3api list-object-versions --bucket "$CDK_PARAM_S3_BUCKET_NAME" --prefix "$CDK_SOURCE_NAME" --query 'Versions[?IsLatest==`true`].{VersionId:VersionId}' --output text 2>&1)

server/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"dependencies": {
1919
"@aws-cdk/aws-lambda-python-alpha": "2.140.0-alpha.0",
20-
"@cdklabs/sbt-aws": "0.4.3",
20+
"@cdklabs/sbt-aws": "0.5.0",
2121
"aws-cdk-lib": "2.140.0",
2222
"constructs": "10.0.5"
2323
}

0 commit comments

Comments
 (0)