-
Notifications
You must be signed in to change notification settings - Fork 14
/
test-regional.sh
41 lines (34 loc) · 2.61 KB
/
test-regional.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
# WELCOME TO CDKitten 🐱
# CDKitten 🐱 is a close cousin of Taskcat 😺
# CDKitten is a simple script to automate test deployment of CDK resources
# to run this script manually navigate to top level directory of the package and sh test-deployment.sh
# this script is a test deployment script for cdk infrastructure
# it accepts a list of regions for test deployment and loops through each region and deploys all cdk infrastructure
# the publish step uses `cdk deploy --all` but this command can be edited to reflect a different stack by editing line
regions=("us-east-1" "us-east-2" "us-west-2") #list of defined regions to loop through for deployment
declare –a success=() #sets an empty list to record successful deployments
for region in "${regions[@]}"
do
echo "Setting aws default region to $region"
export AWS_DEFAULT_REGION=$region #updates local aws config to the region defined for deployment
echo "🚀 deploying cdk app in test to $region 📍"
echo "🥾 bootstrapping cdk in $region 📍"
cdk bootstrap --context adminEmail="test-email@email.com" --context quicksightUserName="test-email@email.com" --context repoBranch="main" --context deployQuicksightStack=false --context deploySagemakerStack=true --context deployWebStack=true --context nagEnabled=true #bootstraps cdk in the region
wait
echo "🚀 deploying all in $region 📍"
cdk deploy --all --context adminEmail="test-email@email.com" --context quicksightUserName="test-email@email.com" --context repoBranch="main" --context deployQuicksightStack=false --context deploySagemakerStack=true --context deployWebStack=true --context nagEnabled=true #deploys all with the optional region context variable
wait
echo "👋 destroying all in $region 📍"
cdk destroy --all --context adminEmail="test-email@email.com" --context quicksightUserName="test-email@email.com" --context repoBranch="main" --context deployQuicksightStack=false --context deploySagemakerStack=true --context deployWebStack=true --context nagEnabled=true #deploys all with the optional region context variable #destroys all cdk resources in the defined region --force flag prevents the required "y" confirmation
wait
success+=("$region") #if the deployment is successful adds the region to the list of successful deployments
done
wait
echo "🥳 Successfully deployed and destroyed all CDK stacks in this testing cycle! 😎"
#loops through list of successful deployments in each region
#prints the list of each region that was successfully deployed
for region in "${success[@]}"
do
echo "✅ successfully deployed and destroyed cdk app in $region 📍"
done