Skip to content

Commit

Permalink
Release: v2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AWS authored and AWS committed May 18, 2023
1 parent fabefd8 commit b1ba765
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 107 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ chmod +x ./deployment/run-unit-tests.sh

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

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

* Update pip version to latest
Expand All @@ -33,7 +34,7 @@ python3 -m pip install -U pip
* Now build the distributable
```
chmod +x ./deployment/build-s3-dist.sh
./deployment/build-s3-dist.sh $DIST_OUTPUT_BUCKET_PREFIX $TEMPLATE_OUTPUT_BUCKET $SOLUTION_NAME $VERSION
./deployment/build-s3-dist.sh $DIST_OUTPUT_BUCKET_PREFIX $TEMPLATE_OUTPUT_BUCKET $SOLUTION_NAME $VERSION $ENABLE_OPT_IN_REGION_SUPPORT
```

* Upload the distributable to an Amazon S3 bucket in your account.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.5.3
v2.6.0
144 changes: 118 additions & 26 deletions customizations-for-aws-control-tower.template

Large diffs are not rendered by default.

63 changes: 45 additions & 18 deletions deployment/build-s3-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
#
# Usage: This script should be executed from the package root directory
# ./deployment/build-s3-dist.sh source-bucket-base-name template-bucket-base-name trademarked-solution-name version-code
# ./deployment/build-s3-dist.sh source-bucket-base-name template-bucket-base-name trademarked-solution-name version-code enable-opt-in-region-support
#
# Parameters:
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
# code from. The template will append '-[region_name]' to this bucket name.
# For example: ./build-s3-dist.sh solutions template-bucket my-solution v1.0.0
# The template will then expect the source code to be located in the solutions-[region_name] bucket
Expand All @@ -14,15 +14,18 @@
#
# - trademarked-solution-name: name of the solution for consistency
#
# - version-code: version of the package
# - version-code: version of the package
#
# - enable-opt-in-region-support: (Optional Boolean) Flag to enable opt-in region support. Pass `true` to set this argument.


# Hard exit on failure
set -e

# Check to see if input has been provided:
if [ $# != 4 ]; then
echo "Please provide the base source bucket name, template-bucket, trademark approved solution name, and version"
echo "For example: ./deployment/build-s3-dist.sh solutions template-bucket trademarked-solution-name v1.0.0"
if [ $# -lt 4 ]; then
echo "Please provide the base source bucket name, template-bucket, trademark approved solution name, version and (Optional) enable-opt-in-region-support flag"
echo "For example: ./deployment/build-s3-dist.sh solutions template-bucket trademarked-solution-name v1.0.0 true"
exit 1
fi

Expand All @@ -34,6 +37,17 @@ CODE_BUCKET_NAME=$1
TEMPLATE_BUCKET_NAME=$2
SOLUTION_NAME=$3
VERSION_NUMBER=$4
ENABLE_OPT_IN_REGION_SUPPORT=$5

# Handle opt-in region builds in backwards compatible way,
# Requires customer to set IS_OPT_IN_REGION parameter
SCRIPT_BUCKET_NAME=$(echo "${TEMPLATE_BUCKET_NAME}")
DISTRIBUTION_BUCKET_NAME=$(echo "${TEMPLATE_BUCKET_NAME}")
if [[ "${ENABLE_OPT_IN_REGION_SUPPORT}" = "true" ]]; then
echo "Building with opt-in region support"
SCRIPT_BUCKET_NAME+='-${AWS_REGION}' # Regionalized Buildspec
DISTRIBUTION_BUCKET_NAME+='-${AWS::Region}' # Regionalized CFN Template
fi

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

echo -e "\n Updating template bucket in the template with $TEMPLATE_BUCKET_NAME"
replace="s/%TEMPLATE_BUCKET_NAME%/$TEMPLATE_BUCKET_NAME/g"
echo -e "\n Updating template bucket in the template with $DISTRIBUTION_BUCKET_NAME"
replace="s/%TEMPLATE_BUCKET_NAME%/$DISTRIBUTION_BUCKET_NAME/g"
echo "sed -i -e $replace $template_dist_dir/custom-control-tower-initiation.template"
sed -i -e "$replace" "$template_dist_dir"/custom-control-tower-initiation.template

echo -e "\n Updating template bucket in the template with $SCRIPT_BUCKET_NAME"
replace="s/%SCRIPT_BUCKET_NAME%/$SCRIPT_BUCKET_NAME/g"
echo "sed -i -e $replace $template_dist_dir/custom-control-tower-initiation.template"
sed -i -e "$replace" "$template_dist_dir"/custom-control-tower-initiation.template

Expand All @@ -93,23 +112,30 @@ zip -Xr "$build_dist_dir"/custom-control-tower-configuration.zip ./*
echo -e "\n*** Build regional config zip file"
# Support all regions in https://docs.aws.amazon.com/controltower/latest/userguide/region-how.html + GovCloud regions
declare -a region_list=(
"us-east-1"
"us-east-2"
"us-west-2"
"ca-central-1"
"ap-southeast-2"
"af-south-1"
"ap-east-1"
"ap-northeast-1"
"ap-northeast-2"
"ap-northeast-3"
"ap-south-1"
"ap-southeast-1"
"ap-southeast-2"
"ap-southeast-3"
"ca-central-1"
"eu-central-1"
"eu-north-1"
"eu-south-1"
"eu-west-1"
"eu-west-2"
"eu-north-1"
"ap-south-1"
"ap-northeast-2"
"ap-northeast-1"
"eu-west-3"
"me-south-1"
"sa-east-1"
"us-gov-west-1"
"us-east-1"
"us-east-2"
"us-gov-east-1"
"us-gov-west-1"
"us-west-1"
"us-west-2"
)
for region in "${region_list[@]}"
do
Expand All @@ -126,3 +152,4 @@ cd -
#Copy Lambda Zip Files to the Global S3 Assets
echo -e "\n Copying lambda zip files to Global S3 Assets"
cp "$build_dist_dir"/*.zip "$template_dist_dir"/

Loading

0 comments on commit b1ba765

Please sign in to comment.