Skip to content

Commit 3e9c2f4

Browse files
Merge branch 'main' into feature/ap/enhanced-search
2 parents 07da807 + 326da2e commit 3e9c2f4

File tree

280 files changed

+14830
-2451
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+14830
-2451
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[*]
2+
charset = utf-8
3+
indent_style = space
4+
indent_size = 2
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true

.gitallowed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source/packages/services/provisioning/src/things/steps/createdevicecertificateprocessor.spec.ts:.*

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"semi": true,
4+
"printWidth": 99
5+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Any other branches besides `main` and the release tags are considered experiment
3434

3535
Implementing, deploying and maintaining IoT services can be significantly more complex than traditional software services due to a number of challenges faced:
3636

37-
**Significant undifferentiated heavy lifting:** It can take months, if not years, to build out an IoT platform.
37+
**Significant undifferentiated heavy lifting:** It can take months, if not years, to build out an Facade API.
3838

3939
**Skills gap:** Finding product and IoT specialists is one problem, but then needing to find those same people who possess AWS knowledge is significantly harder.
4040

multi-accounts/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The transformation scripts in this folder are used when you want to deploy `aws-connected-device-framework` in multiple account mode. It replaces some of the the parameters in cloudformation from `String` to `AWS::SSM::Parameter::Value<String>` to allow one stack to refer to another stack resources using ssm parameter store.

multi-accounts/build-s3-dist.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/bash
2+
#-----------------------------------------------------------------------------------------------------------------------
3+
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
6+
# with the License. A copy of the License is located at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
11+
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
12+
# and limitations under the License.
13+
#-----------------------------------------------------------------------------------------------------------------------
14+
15+
#
16+
# This assumes all of the OS-level configuration has been completed and git repo has already been cloned
17+
#
18+
# This script should be run from the repo's deployment directory
19+
# cd deployment
20+
# ./build-s3-dist.sh source-bucket-base-name solution-name version-code
21+
#
22+
# Parameters:
23+
# - source-bucket-base-name: Name for the S3 bucket location where the template will source the Lambda
24+
# code from. The template will append '-[region_name]' to this bucket name.
25+
# For example: ./build-s3-dist.sh solutions my-solution v1.0.0
26+
# The template will then expect the source code to be located in the solutions-[region_name] bucket
27+
#
28+
# - solution-name: name of the solution for consistency
29+
#
30+
# - version-code: version of the package
31+
32+
# Check to see if input has been provided:
33+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ] ; then
34+
echo "Please provide the base source bucket name, trademark approved solution name and version where the lambda code will eventually reside."
35+
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.0"
36+
exit 1
37+
fi
38+
39+
# Get reference for all important folders
40+
template_dir="$PWD"
41+
template_dist_dir="$template_dir/global-s3-assets"
42+
build_dist_dir="$template_dir/regional-s3-assets"
43+
source_dir="$template_dir/../source"
44+
45+
echo "------------------------------------------------------------------------------"
46+
echo "[Init] Clean old dist, node_modules and bower_components folders"
47+
echo "------------------------------------------------------------------------------"
48+
echo "rm -rf $template_dist_dir"
49+
rm -rf $template_dist_dir
50+
echo "mkdir -p $template_dist_dir"
51+
mkdir -p $template_dist_dir
52+
echo "rm -rf $build_dist_dir"
53+
rm -rf $build_dist_dir
54+
echo "mkdir -p $build_dist_dir"
55+
mkdir -p $build_dist_dir
56+
57+
58+
echo "------------------------------------------------------------------------------"
59+
echo "[Packing] Templates"
60+
echo "------------------------------------------------------------------------------"
61+
62+
# copy all the cfn templates in the source/infrastructure dir
63+
cp $source_dir/infrastructure/cfn-sample-tenant-component.yaml $template_dist_dir/
64+
# copy all the cfn templates in source/infrastructure/lambdaLayers/openssl/infrastructure
65+
cp $source_dir/infrastructure/lambdaLayers/openssl/infrastructure/cfn-*.yml $template_dist_dir/
66+
# copy all the cfn templates ending in yml in source/package/*/infrastructure
67+
cp $source_dir/packages/services/*/infrastructure/cfn-command-and-control.yml $template_dist_dir/
68+
# copy all cfn template snippets
69+
cp -a $source_dir/infrastructure/cloudformation/snippets/ $template_dist_dir/snippets/
70+
# copy all cfn templates in libraries/core
71+
cp $source_dir/packages/libraries/core/*/infrastructure/cfn-deployment-helper.yaml $template_dist_dir/
72+
73+
cd "$template_dist_dir"
74+
# Rename all *.yaml to *.template
75+
for f in *.yaml; do
76+
mv -- "$f" "${f%.yaml}.template"
77+
done
78+
79+
# Rename all *.yml to *.template
80+
for f in *.yml; do
81+
mv -- "$f" "${f%.yml}.template"
82+
done
83+
84+
# remove non-release templates
85+
rm "$template_dist_dir"/cfn-auth-jwt.template
86+
rm "$template_dist_dir"/cfn-auth-devicecert.template
87+
rm "$template_dist_dir"/cfn-cdf-core*
88+
rm "$template_dist_dir"/cfn-bastion-host.template
89+
90+
# override the S3 Code Uri and TemplateURL for the cfn templates to point to a S3 location
91+
for f in *.template; do
92+
if [ -f "../transforms/${f%.*}.yaml" ]; then
93+
# Below only works in yq version 3.4.1
94+
yq w -i -s "../transforms/${f%.*}.yaml" "$f"
95+
fi
96+
done
97+
98+
cd ..
99+
echo "Updating code source bucket in template with $1"
100+
replace="s/%%BUCKET_NAME%%/$1/g"
101+
echo "sed -i '' -e $replace $template_dist_dir/*.template"
102+
sed -i '' -e $replace $template_dist_dir/*.template
103+
replace="s/%%SOLUTION_NAME%%/$2/g"
104+
echo "sed -i '' -e $replace $template_dist_dir/*.template"
105+
sed -i '' -e $replace $template_dist_dir/*.template
106+
replace="s/%%VERSION%%/$3/g"
107+
echo "sed -i '' -e $replace $template_dist_dir/*.template"
108+
sed -i '' -e $replace $template_dist_dir/*.template
109+
110+
replace="s/%%TEMPLATE_BUCKET_NAME%%/$4/g"
111+
sed -i '' -e $replace $template_dist_dir/*.template
112+
113+
114+
echo "------------------------------------------------------------------------------"
115+
echo "[Rebuild] Package Dists"
116+
echo "------------------------------------------------------------------------------"
117+
118+
# Copy and rename dists
119+
cd $build_dist_dir
120+
cp $source_dir/packages/libraries/core/deployment-helper/bundle.zip $build_dist_dir/cdf-deployment-helper.zip
121+
cp $source_dir/infrastructure/lambdaLayers/openssl/build/build.zip $build_dist_dir/cdf-openssl-layer.zip
122+
cp $source_dir/packages/services/provisioning/bundle.zip $build_dist_dir/cdf-provisioning.zip
123+
cp $source_dir/packages/services/command-and-control/bundle.zip $build_dist_dir/cdf-command-and-control.zip
124+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
CDF_LOCATION=$(pwd)
6+
source "$CDF_LOCATION/source/infrastructure/common-deploy-functions.bash"
7+
8+
function help_message {
9+
cat << EOF
10+
11+
NAME:
12+
deploy-assets-multiple-regions.bash
13+
14+
DESCRIPTION:
15+
Deploys assets in multiple regions.
16+
17+
MANDATORY ARGUMENTS:
18+
====================
19+
-p (string) Name of the Bucket Prefix
20+
-b (string) Name of the Template Bucket
21+
-r (string) List of supported regions separated by space
22+
-v (string) Version of the template
23+
24+
OPTIONAL ARGUMENTS
25+
26+
------------
27+
-R (string) AWS region.
28+
-P (string) AWS profile.
29+
30+
DEPENDENCIES REQUIRED:
31+
32+
- aws-cli
33+
- jq
34+
- zip
35+
36+
EOF
37+
}
38+
39+
##########################################################
40+
###### parse and validate the provided arguments ######
41+
##########################################################
42+
while getopts ":b:p:r:v:R:P:" opt; do
43+
case $opt in
44+
b ) export TEMPLATE_BUCKET_NAME=$OPTARG;;
45+
p ) export BUCKET_NAME_PREFIX=$OPTARG;;
46+
r ) export SUPPORTED_REGIONS=$OPTARG;;
47+
v ) export SOLUTION_VERSION=$OPTARG;;
48+
49+
R ) export AWS_REGION=$OPTARG;;
50+
P ) export AWS_PROFILE=$OPTARG;;
51+
52+
\? ) echo "Unknown option: -$OPTARG" >&2; help_message; exit 1;;
53+
: ) echo "Missing option argument for -$OPTARG" >&2; help_message; exit 1;;
54+
* ) echo "Unimplemented option: -$OPTARG" >&2; help_message; exit 1;;
55+
esac
56+
done
57+
58+
if [[ "$DEBUG" == "true" ]]; then
59+
set -x
60+
fi
61+
62+
63+
IFS=' ' read -ra SUPPORTED_REGIONS_ARRAY <<< "$SUPPORTED_REGIONS"
64+
65+
AWS_ARGS=$(buildAwsArgs "$AWS_REGION" "$AWS_PROFILE" )
66+
SOLUTION_NAME="aws-connected-device-framework"
67+
68+
###########################################################################
69+
###### transform CDF templates to work in multi account environment ######
70+
###########################################################################
71+
cd "$CDF_LOCATION"/multi-accounts
72+
73+
./build-s3-dist.sh "$BUCKET_NAME_PREFIX" "$SOLUTION_NAME" "$SOLUTION_VERSION" "$TEMPLATE_BUCKET_NAME"
74+
75+
global_s3_assets="$CDF_LOCATION"/multi-accounts/global-s3-assets
76+
regional_s3_assets="$CDF_LOCATION"/multi-accounts/regional-s3-assets
77+
78+
cd "$global_s3_assets"
79+
80+
for region in "${SUPPORTED_REGIONS_ARRAY[@]}"
81+
do
82+
artifact_key="${BUCKET_NAME_PREFIX}-${region}/$SOLUTION_NAME/$SOLUTION_VERSION"
83+
aws s3 sync --acl bucket-owner-full-control $AWS_ARGS . "s3://${artifact_key}"
84+
done
85+
86+
cd "$regional_s3_assets"
87+
for region in "${SUPPORTED_REGIONS_ARRAY[@]}"
88+
do
89+
artifact_key="${BUCKET_NAME_PREFIX}-${region}/$SOLUTION_NAME/$SOLUTION_VERSION"
90+
aws s3 sync --acl bucket-owner-full-control $AWS_ARGS . "s3://${artifact_key}"
91+
done

0 commit comments

Comments
 (0)