2
2
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
3
3
#
4
4
# Usage: This script should be executed from the package root directory
5
- # ./deployment/build-s3-dist.sh source-bucket-base-name template-bucket-base-name trademarked-solution-name version-code
5
+ # ./deployment/build-s3-dist.sh source-bucket-base-name template-bucket-base-name trademarked-solution-name version-code enable-opt-in-region-support
6
6
#
7
7
# Parameters:
8
- # - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
8
+ # - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
9
9
# code from. The template will append '-[region_name]' to this bucket name.
10
10
# For example: ./build-s3-dist.sh solutions template-bucket my-solution v1.0.0
11
11
# The template will then expect the source code to be located in the solutions-[region_name] bucket
14
14
#
15
15
# - trademarked-solution-name: name of the solution for consistency
16
16
#
17
- # - version-code: version of the package
17
+ # - version-code: version of the package
18
+ #
19
+ # - enable-opt-in-region-support: (Optional Boolean) Flag to enable opt-in region support. Pass `true` to set this argument.
20
+
18
21
19
22
# Hard exit on failure
20
23
set -e
21
24
22
25
# Check to see if input has been provided:
23
- if [ $# != 4 ]; then
24
- echo " Please provide the base source bucket name, template-bucket, trademark approved solution name, and version "
25
- echo " For example: ./deployment/build-s3-dist.sh solutions template-bucket trademarked-solution-name v1.0.0"
26
+ if [ $# -lt 4 ]; then
27
+ echo " Please provide the base source bucket name, template-bucket, trademark approved solution name, version and (Optional) enable-opt-in-region-support flag "
28
+ echo " For example: ./deployment/build-s3-dist.sh solutions template-bucket trademarked-solution-name v1.0.0 true "
26
29
exit 1
27
30
fi
28
31
@@ -34,6 +37,17 @@ CODE_BUCKET_NAME=$1
34
37
TEMPLATE_BUCKET_NAME=$2
35
38
SOLUTION_NAME=$3
36
39
VERSION_NUMBER=$4
40
+ ENABLE_OPT_IN_REGION_SUPPORT=$5
41
+
42
+ # Handle opt-in region builds in backwards compatible way,
43
+ # Requires customer to set IS_OPT_IN_REGION parameter
44
+ SCRIPT_BUCKET_NAME=$( echo " ${TEMPLATE_BUCKET_NAME} " )
45
+ DISTRIBUTION_BUCKET_NAME=$( echo " ${TEMPLATE_BUCKET_NAME} " )
46
+ if [[ " ${ENABLE_OPT_IN_REGION_SUPPORT} " = " true" ]]; then
47
+ echo " Building with opt-in region support"
48
+ SCRIPT_BUCKET_NAME+=' -${AWS_REGION}' # Regionalized Buildspec
49
+ DISTRIBUTION_BUCKET_NAME+=' -${AWS::Region}' # Regionalized CFN Template
50
+ fi
37
51
38
52
echo " ------------------------------------------------------------------------------"
39
53
echo " [Init] Clean old dist and recreate directories"
@@ -68,8 +82,13 @@ replace="s/%DIST_BUCKET_NAME%/$CODE_BUCKET_NAME/g"
68
82
echo " sed -i -e $replace $template_dist_dir /custom-control-tower-initiation.template"
69
83
sed -i -e " $replace " " $template_dist_dir " /custom-control-tower-initiation.template
70
84
71
- echo -e " \n Updating template bucket in the template with $TEMPLATE_BUCKET_NAME "
72
- replace=" s/%TEMPLATE_BUCKET_NAME%/$TEMPLATE_BUCKET_NAME /g"
85
+ echo -e " \n Updating template bucket in the template with $DISTRIBUTION_BUCKET_NAME "
86
+ replace=" s/%TEMPLATE_BUCKET_NAME%/$DISTRIBUTION_BUCKET_NAME /g"
87
+ echo " sed -i -e $replace $template_dist_dir /custom-control-tower-initiation.template"
88
+ sed -i -e " $replace " " $template_dist_dir " /custom-control-tower-initiation.template
89
+
90
+ echo -e " \n Updating template bucket in the template with $SCRIPT_BUCKET_NAME "
91
+ replace=" s/%SCRIPT_BUCKET_NAME%/$SCRIPT_BUCKET_NAME /g"
73
92
echo " sed -i -e $replace $template_dist_dir /custom-control-tower-initiation.template"
74
93
sed -i -e " $replace " " $template_dist_dir " /custom-control-tower-initiation.template
75
94
@@ -93,23 +112,30 @@ zip -Xr "$build_dist_dir"/custom-control-tower-configuration.zip ./*
93
112
echo -e " \n*** Build regional config zip file"
94
113
# Support all regions in https://docs.aws.amazon.com/controltower/latest/userguide/region-how.html + GovCloud regions
95
114
declare -a region_list=(
96
- " us-east-1"
97
- " us-east-2"
98
- " us-west-2"
99
- " ca-central-1"
100
- " ap-southeast-2"
115
+ " af-south-1"
116
+ " ap-east-1"
117
+ " ap-northeast-1"
118
+ " ap-northeast-2"
119
+ " ap-northeast-3"
120
+ " ap-south-1"
101
121
" ap-southeast-1"
122
+ " ap-southeast-2"
123
+ " ap-southeast-3"
124
+ " ca-central-1"
102
125
" eu-central-1"
126
+ " eu-north-1"
127
+ " eu-south-1"
103
128
" eu-west-1"
104
129
" eu-west-2"
105
- " eu-north-1"
106
- " ap-south-1"
107
- " ap-northeast-2"
108
- " ap-northeast-1"
109
130
" eu-west-3"
131
+ " me-south-1"
110
132
" sa-east-1"
111
- " us-gov-west-1"
133
+ " us-east-1"
134
+ " us-east-2"
112
135
" us-gov-east-1"
136
+ " us-gov-west-1"
137
+ " us-west-1"
138
+ " us-west-2"
113
139
)
114
140
for region in " ${region_list[@]} "
115
141
do
126
152
# Copy Lambda Zip Files to the Global S3 Assets
127
153
echo -e " \n Copying lambda zip files to Global S3 Assets"
128
154
cp " $build_dist_dir " /* .zip " $template_dist_dir " /
155
+
0 commit comments