Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit a19a2cc

Browse files
committed
Update to version v2.3.0
1 parent de1ce0f commit a19a2cc

31 files changed

+987
-6885
lines changed

CHANGELOG.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,92 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.3.0] - 2023-03-30
8+
- Support S3 Access Key Rotation
79

8-
## [1.0.0] - 2022-01-04
10+
## [2.0.2] - 2021-06-19
11+
12+
### Changed
13+
14+
- Use Secrets Manager to store credentials
15+
- Use container image on Amazon ECR Public Gallery
16+
17+
### Added
18+
- Implement auto shutdown on EC2 instances when error occurred
19+
20+
### Fixed
21+
22+
- Potential out of memory issue on EC2 when transferring large files
23+
- Incorrect part number and chunk size for file over 50GB
24+
25+
26+
27+
## [2.0.1] - 2021-04-23
28+
29+
### Changed
30+
31+
- Support custom endpoint url
32+
- Support object ACL
33+
34+
35+
## [2.0.0] - 2021-03-17
36+
37+
### Changed
38+
39+
- Use EC2 + Auto Scaling Group to replace Lambda to do data transfer
40+
- Rewrite core logic in golang (Separate project)
41+
- Support cross account deployment
42+
43+
44+
## [1.3.0] - 2020-12-30
45+
46+
### Changed
47+
- Regroup the cloudformation parameters
48+
49+
### Added
50+
- Add support of S3 Delete Event
51+
52+
## [1.2.0] - 2020-12-24
53+
54+
### Fixed
55+
- Fix wrong metric name in Lambda-NETWORK widget
56+
57+
### Changed
58+
- Use S3 Native SDK to access and get objects from Aliyun OSS
59+
- Region name is now one of the stack parameters. Aligned with ECR plugin.
60+
61+
### Added
62+
- Add support of replicating from Google Cloud Storage to Amazon S3 (Global)
63+
64+
## [1.1.0] - 2020-12-21
65+
66+
### Changed
67+
- Use custom provider to handling stack events
68+
69+
### Added
70+
- Add support of triggering replication base on S3 Event.
71+
72+
## [1.0.2] - 2020-12-06
73+
74+
### Changed
75+
- Change to use CDK v1.74.0
76+
- Reduce the number of logs generated.
77+
78+
### Added
79+
- Add support of accessing s3 with no-sign-request
80+
81+
## [1.0.1] - 2020-11-16
82+
### Added
83+
- Advanced options to control replication process, such as lambda memory, chunk size etc.
84+
- Support of choosing different destination storage class
85+
86+
### Fixed
87+
- Cloudformation parameters are not grouped and ordered
88+
89+
### Changed
90+
- ECR image is now tagged with version number.
91+
92+
93+
## [1.0.0] - 2020-09-30
994
### Added
1095
- All files, initial version

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ If you discover a potential security issue in this project we ask that you notif
5656

5757
## Licensing
5858

59-
See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
59+
See the [LICENSE](https://github.com/awslabs/amazon-s3-data-replication-hub-plugin/blob/main/LICENSE.txt) file for our project's licensing. We will ask you to confirm the licensing of your contribution.

NOTICE.txt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
Data Transfer Hub - S3 Plugin
2-
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3-
Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except
4-
in compliance with the License. A copy of the License is located at http://www.apache.org/licenses/
5-
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
6-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied. See the License for the
7-
specific language governing permissions and limitations under the License.
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
83

94
**********************
105
THIRD PARTY COMPONENTS
116
**********************
127
This software includes third party software subject to the following copyrights:
138

14-
AWS SDK under the Apache License Version 2.0
9+
aws-cdk under the Apache License 2.0
10+
aws-cdk-lib under the Apache License 2.0
11+
cdk-nag under the Apache License 2.0
12+
constructs under the Apache License 2.0
13+
source-map-support under the Massachusetts Institute of Technology (MIT) license
14+
@types/jest under the Massachusetts Institute of Technology (MIT) license
15+
@types/node under the Massachusetts Institute of Technology (MIT) license
16+
aws-sdk under the Apache License 2.0
17+
jest under the Massachusetts Institute of Technology (MIT) license
18+
path-parse under the Massachusetts Institute of Technology (MIT) license
19+
ts-jest under the Massachusetts Institute of Technology (MIT) license
20+
ts-node under the Massachusetts Institute of Technology (MIT) license
21+
typescript under the Apache License 2.0

deployment/build-s3-dist.sh

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ if [ -z "$1" ] || [ -z "$2" ] ; then
4747
fi
4848

4949
# Get default version
50-
if [ -z "$3" ]; then
51-
export VERSION=$(git describe --tags || echo v0.0.0)
50+
if [ ! -z $3 ]; then
51+
export VERSION="$3"
5252
else
53-
export VERSION=$3
53+
export VERSION=$(git describe --tags --exact-match || { [ -n "$BRANCH_NAME" ] && echo "$BRANCH_NAME"; } || echo v0.0.0)
5454
fi
5555

5656
# Get reference for all important folders
@@ -67,7 +67,7 @@ echo "--------------------------------------------------------------------------
6767
echo AWS_DEFAULT_REGION $AWS_DEFAULT_REGION
6868
echo DIST_OUTPUT_BUCKET $1
6969
echo SOLUTION_NAME $2
70-
echo REGION $REGION
70+
# echo REGION $REGION
7171

7272
echo "------------------------------------------------------------------------------"
7373
echo "[Init] Remove any old dist files from previous runs"
@@ -103,10 +103,6 @@ echo "--------------------------------------------------------------------------
103103
echo "cd $source_dir"
104104
cd $source_dir
105105

106-
# Install and build
107-
echo "npm run build"
108-
npm run build
109-
110106
# Run 'cdk synth' to generate raw solution outputs
111107
echo "cdk synth --output=$staging_dist_dir"
112108
npx cdk synth -j --output=$staging_dist_dir -c runType=EC2 > $staging_dist_dir/DataTransferS3Stack-ec2.template.json
@@ -181,22 +177,39 @@ for d in `find . -mindepth 1 -maxdepth 1 -type d`; do
181177
# cd $d
182178
# Rename the artifact, removing the period for handler compatibility
183179
pfname="$(basename -- $d)"
184-
fname="$(echo $pfname | sed -e 's/\.//g')"
185-
echo "zipping the artifact"
186-
mv $d $fname
187-
pushd $fname
188-
echo "zip -qr9 $staging_dist_dir/$fname.zip ."
189-
zip -qr9 $staging_dist_dir/$fname.zip .
190-
popd
191-
192-
# Copy the zipped artifact from /staging to /regional-s3-assets
193-
echo "mv $fname.zip $build_dist_dir"
194-
mv $fname.zip $build_dist_dir
180+
# zip folder
181+
echo "zip -rq $pfname.zip $pfname"
182+
cd $pfname
183+
zip -rq $pfname.zip *
184+
mv $pfname.zip ../
185+
cd ..
195186

196187
# Remove the old, unzipped artifact from /staging
197-
echo "rm -rf $fname"
198-
rm -rf $fname
188+
echo "rm -rf $pfname"
189+
rm -rf $pfname
190+
191+
# ... repeat until all source code artifacts are zipped and placed in the /staging
192+
done
193+
194+
195+
# ... For each asset.*.zip code artifact in the temporary /staging folder...
196+
cd $staging_dist_dir
197+
for f in `find . -iname \*.zip`; do
198+
# Rename the artifact, removing the period for handler compatibility
199+
# pfname = asset.<key-name>.zip
200+
pfname="$(basename -- $f)"
201+
echo $pfname
202+
# fname = <key-name>.zip
203+
fname="$(echo $pfname | sed -e 's/asset\.//g')"
204+
mv $pfname $fname
205+
206+
# Copy the zipped artifact from /staging to /regional-s3-assets
207+
echo "cp $fname $build_dist_dir"
208+
cp $fname $build_dist_dir
199209

210+
# Remove the old, zipped artifact from /staging
211+
echo "rm $fname"
212+
rm $fname
200213
done
201214

202215
echo "------------------------------------------------------------------------------"

deployment/cdk-solution-helper/index.js

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ fs.readdirSync(global_s3_assets).forEach(file => {
3333
const fn = template.Resources[f];
3434
if (fn.Properties.Code.hasOwnProperty('S3Bucket')) {
3535
// Set the S3 key reference
36-
let artifactHash = Object.assign(fn.Properties.Code.S3Bucket.Ref);
37-
// artifactHash = artifactHash.replace('AssetParameters', '');
38-
let start = artifactHash.indexOf('AssetParameters') + 15
39-
artifactHash = artifactHash.substring(start, artifactHash.indexOf('S3Bucket'));
40-
const assetPath = `asset${artifactHash}`;
41-
fn.Properties.Code.S3Key = `%%SOLUTION_NAME%%/%%VERSION%%/${assetPath}.zip`;
36+
let s3Key = Object.assign(fn.Properties.Code.S3Key);
37+
// https://github.com/aws/aws-cdk/issues/10608
38+
if (!s3Key.endsWith('.zip')) {
39+
fn.Properties.Code.S3Key = `%%SOLUTION_NAME%%/%%VERSION%%/${s3Key}.zip`;
40+
} else {
41+
fn.Properties.Code.S3Key = `%%SOLUTION_NAME%%/%%VERSION%%/${s3Key}`;
42+
}
4243
// Set the S3 bucket reference
4344
fn.Properties.Code.S3Bucket = {
4445
'Fn::Sub': '%%BUCKET_NAME%%-${AWS::Region}'
@@ -67,58 +68,20 @@ fs.readdirSync(global_s3_assets).forEach(file => {
6768
}
6869
});
6970

70-
// Clean-up Lambda layer code dependencies
71+
// Clean-up Lambda Layer code dependencies
7172
const lambdaLayers = Object.keys(resources).filter(function (key) {
7273
return resources[key].Type === "AWS::Lambda::LayerVersion";
73-
});
74-
lambdaLayers.forEach(function (f) {
75-
const fn = template.Resources[f];
76-
if (fn.Properties.Content.hasOwnProperty('S3Bucket')) {
77-
// Set the S3 key reference
78-
let artifactHash = Object.assign(fn.Properties.Content.S3Bucket.Ref);
79-
// artifactHash = artifactHash.replace('AssetParameters', '');
80-
let start = artifactHash.indexOf('AssetParameters') + 15
81-
artifactHash = artifactHash.substring(start, artifactHash.indexOf('S3Bucket'));
82-
const assetPath = `asset${artifactHash}`;
83-
fn.Properties.Content.S3Key = `%%SOLUTION_NAME%%/%%VERSION%%/${assetPath}.zip`;
84-
// Set the S3 bucket reference
85-
fn.Properties.Content.S3Bucket = {
74+
})
75+
lambdaLayers.forEach(function (l) {
76+
const layer = template.Resources[l];
77+
if (layer.Properties.Content.hasOwnProperty('S3Bucket')) {
78+
let s3Key = Object.assign(layer.Properties.Content.S3Key);
79+
layer.Properties.Content.S3Key = `%%SOLUTION_NAME%%/%%VERSION%%/${s3Key}`;
80+
layer.Properties.Content.S3Bucket = {
8681
'Fn::Sub': '%%BUCKET_NAME%%-${AWS::Region}'
87-
};
88-
// // Set the handler
89-
// const handler = fn.Properties.Handler;
90-
// fn.Properties.Handler = `${assetPath}/${handler}`;
91-
}
92-
});
93-
94-
// Clean-up nested template stack dependencies
95-
const nestedStacks = Object.keys(resources).filter(function (key) {
96-
return resources[key].Type === 'AWS::CloudFormation::Stack'
97-
});
98-
nestedStacks.forEach(function (f) {
99-
const fn = template.Resources[f];
100-
fn.Properties.TemplateURL = {
101-
'Fn::Join': [
102-
'',
103-
[
104-
fn.Metadata.domain,
105-
'/',
106-
`%%SOLUTION_NAME%%/%%VERSION%%/${fn.Metadata.nestedTemplateName}`
107-
]
108-
]
109-
};
110-
111-
const params = fn.Properties.Parameters ? fn.Properties.Parameters : {};
112-
const nestedStackParameters = Object.keys(params).filter(function (key) {
113-
if (key.search(/[\w]*AssetParameters/g) > -1) {
114-
return true;
11582
}
116-
return false;
117-
});
118-
nestedStackParameters.forEach(function (stkParam) {
119-
fn.Properties.Parameters[stkParam] = undefined;
120-
});
121-
});
83+
}
84+
})
12285

12386

12487
// Clean-up parameters section
@@ -130,6 +93,17 @@ fs.readdirSync(global_s3_assets).forEach(file => {
13093
template.Parameters[a] = undefined;
13194
});
13295

96+
// Clean-up BootstrapVersion parameter
97+
if (parameters.hasOwnProperty('BootstrapVersion')) {
98+
parameters.BootstrapVersion = undefined
99+
}
100+
101+
// Clean-up CheckBootstrapVersion Rule
102+
const rules = (template.Rules) ? template.Rules : {};
103+
if (rules.hasOwnProperty('CheckBootstrapVersion')) {
104+
rules.CheckBootstrapVersion = undefined
105+
}
106+
133107
// Output modified template file
134108
const output_template = JSON.stringify(template, null, 2);
135109
fs.writeFileSync(`${global_s3_assets}/${file}`, output_template);

docs/DEPLOYMENT_CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
[![Launch Stack](launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=DTHS3Stack&templateURL=https://solutions-reference.s3.amazonaws.com/data-transfer-hub-s3-plugin/latest/DataTransferS3Stack-ec2.template)
6565

6666

67+
6768
1. 单击**下一步**。 相应地为参数指定值。 如果需要,请更改堆栈名称。
6869

6970
1. 单击**下一步**。 配置其他堆栈选项,例如标签(可选)。

source/bin/main-stack.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,31 @@ limitations under the License.
1818

1919

2020
import 'source-map-support/register';
21-
import * as cdk from '@aws-cdk/core';
21+
import { App, Aspects, Stack } from "aws-cdk-lib";
2222
import { DataTransferS3Stack } from '../lib/main-stack';
2323

24-
const app = new cdk.App();
25-
new DataTransferS3Stack(app, 'DataTransferS3Stack');
24+
import {
25+
AwsSolutionsChecks,
26+
NagPackSuppression,
27+
NagSuppressions,
28+
} from "cdk-nag";
29+
30+
const app = new App();
31+
32+
function stackSuppressions(
33+
stacks: Stack[],
34+
suppressions: NagPackSuppression[]
35+
) {
36+
stacks.forEach((s) =>
37+
NagSuppressions.addStackSuppressions(s, suppressions, true)
38+
);
39+
}
40+
41+
stackSuppressions([
42+
new DataTransferS3Stack(app, 'DataTransferS3Stack'),
43+
], [
44+
{ id: 'AwsSolutions-IAM5', reason: 'some policies need to get dynamic resources' },
45+
{ id: 'AwsSolutions-IAM4', reason: 'these policies is used by CDK Customer Resource lambda' },
46+
]);
47+
48+
Aspects.of(app).add(new AwsSolutionsChecks());

source/cdk.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"app": "npx ts-node bin/main-stack.ts",
33
"context": {
4-
"@aws-cdk/core:enableStackNameDuplicates": "true",
54
"aws-cdk:enableDiffNoFail": "true"
65
}
76
}

source/lambda/.coveragerc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[run]
2+
omit =
3+
tests/*
4+
.venv-*/*
5+
test/*
6+
*/__init__.py
7+
assets/*
8+
source =
9+
.

0 commit comments

Comments
 (0)