Skip to content

Commit b1ba765

Browse files
AWSAWS
authored andcommitted
Release: v2.6.0
1 parent fabefd8 commit b1ba765

File tree

7 files changed

+343
-107
lines changed

7 files changed

+343
-107
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ chmod +x ./deployment/run-unit-tests.sh
1515

1616
## Building the customized solution
1717
* Building the solution from source requires Python 3.6 or higher
18-
* Configure the solution name, version number and bucket name of your target Amazon S3 distribution bucket
18+
* Configure the solution name, version number, bucket name and (optional) opt-in region support of your target Amazon S3 distribution bucket
1919

2020
```
2121
export DIST_OUTPUT_BUCKET_PREFIX=my-bucket-prefix # Prefix for the S3 bucket where customized code will be stored
2222
export TEMPLATE_OUTPUT_BUCKET=my-bucket-name # Name for the S3 bucket where the template will be stored
2323
export SOLUTION_NAME=my-solution-name # name of the solution (e.g. customizations-for-aws-control-tower)
2424
export VERSION=my-version # version number for the customized code (e.g. 2.1.0)
25+
export ENABLE_OPT_IN_REGION_SUPPORT=true # Optional flag to build with opt-in region support
2526
```
2627

2728
* Update pip version to latest
@@ -33,7 +34,7 @@ python3 -m pip install -U pip
3334
* Now build the distributable
3435
```
3536
chmod +x ./deployment/build-s3-dist.sh
36-
./deployment/build-s3-dist.sh $DIST_OUTPUT_BUCKET_PREFIX $TEMPLATE_OUTPUT_BUCKET $SOLUTION_NAME $VERSION
37+
./deployment/build-s3-dist.sh $DIST_OUTPUT_BUCKET_PREFIX $TEMPLATE_OUTPUT_BUCKET $SOLUTION_NAME $VERSION $ENABLE_OPT_IN_REGION_SUPPORT
3738
```
3839

3940
* Upload the distributable to an Amazon S3 bucket in your account.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.5.3
1+
v2.6.0

customizations-for-aws-control-tower.template

Lines changed: 118 additions & 26 deletions
Large diffs are not rendered by default.

deployment/build-s3-dist.sh

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
33
#
44
# 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
66
#
77
# 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
99
# code from. The template will append '-[region_name]' to this bucket name.
1010
# For example: ./build-s3-dist.sh solutions template-bucket my-solution v1.0.0
1111
# The template will then expect the source code to be located in the solutions-[region_name] bucket
@@ -14,15 +14,18 @@
1414
#
1515
# - trademarked-solution-name: name of the solution for consistency
1616
#
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+
1821

1922
# Hard exit on failure
2023
set -e
2124

2225
# 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"
2629
exit 1
2730
fi
2831

@@ -34,6 +37,17 @@ CODE_BUCKET_NAME=$1
3437
TEMPLATE_BUCKET_NAME=$2
3538
SOLUTION_NAME=$3
3639
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
3751

3852
echo "------------------------------------------------------------------------------"
3953
echo "[Init] Clean old dist and recreate directories"
@@ -68,8 +82,13 @@ replace="s/%DIST_BUCKET_NAME%/$CODE_BUCKET_NAME/g"
6882
echo "sed -i -e $replace $template_dist_dir/custom-control-tower-initiation.template"
6983
sed -i -e "$replace" "$template_dist_dir"/custom-control-tower-initiation.template
7084

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"
7392
echo "sed -i -e $replace $template_dist_dir/custom-control-tower-initiation.template"
7493
sed -i -e "$replace" "$template_dist_dir"/custom-control-tower-initiation.template
7594

@@ -93,23 +112,30 @@ zip -Xr "$build_dist_dir"/custom-control-tower-configuration.zip ./*
93112
echo -e "\n*** Build regional config zip file"
94113
# Support all regions in https://docs.aws.amazon.com/controltower/latest/userguide/region-how.html + GovCloud regions
95114
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"
101121
"ap-southeast-1"
122+
"ap-southeast-2"
123+
"ap-southeast-3"
124+
"ca-central-1"
102125
"eu-central-1"
126+
"eu-north-1"
127+
"eu-south-1"
103128
"eu-west-1"
104129
"eu-west-2"
105-
"eu-north-1"
106-
"ap-south-1"
107-
"ap-northeast-2"
108-
"ap-northeast-1"
109130
"eu-west-3"
131+
"me-south-1"
110132
"sa-east-1"
111-
"us-gov-west-1"
133+
"us-east-1"
134+
"us-east-2"
112135
"us-gov-east-1"
136+
"us-gov-west-1"
137+
"us-west-1"
138+
"us-west-2"
113139
)
114140
for region in "${region_list[@]}"
115141
do
@@ -126,3 +152,4 @@ cd -
126152
#Copy Lambda Zip Files to the Global S3 Assets
127153
echo -e "\n Copying lambda zip files to Global S3 Assets"
128154
cp "$build_dist_dir"/*.zip "$template_dist_dir"/
155+

0 commit comments

Comments
 (0)