Skip to content

Commit 0fffb8f

Browse files
authored
Merge pull request #90 from aws-solutions/develop
Enabled bucket policy for logging S3 bucket to allow secure transport only
2 parents 47357ba + bff4403 commit 0fffb8f

File tree

4 files changed

+115
-14
lines changed

4 files changed

+115
-14
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.2] - 2022-03-31
9+
10+
### Added
11+
12+
- Enabled encryption in transit for the logging S3 bucket.
13+
814
## [2.0.1] - 2021-12-13
915

1016
Version 2.0.1 supports upgrading from version 2.0.0 but not from version 1.3.0 and below
@@ -58,14 +64,14 @@ Version 2.0.0 does not support upgrading from previous versions.
5864
- Added StartedBy tag to tasks for use by task listing functions
5965
- Modified all ECS task listing functions to support listing 1000 tasks
6066
- Modified TaskRunning lambda function to support being called multiple times from step functions
61-
- Tests start simultaneously
67+
- Tests start simultaneously
6268
- Added ecscontroller.py to container package
6369
- Added ecslistener.py to container package
6470
- TaskRunner lambda launches worker tasks first, then leader task once workers are running
6571
- Run tests concurrently
6672
- Removed disabling of submit buttons if there is a test running
6773
- Unbuffered bzt output and added test Id to CloudWatch logs for access to test specific logs
68-
- Added support for Docker Hub login
74+
- Added support for Docker Hub login
6975
- Added Secrets manager parameter to include secret containing Docker Hub credentials
7076
- Included more metrics
7177
- Added virtual users, failures, and successes to graph

source/infrastructure/lib/common-resources.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import { Aws, CfnCondition, CfnCustomResource, CfnResource, Construct, CustomResource, Duration, RemovalPolicy, Stack, Tags } from '@aws-cdk/core';
44
import { BlockPublicAccess, Bucket, BucketAccessControl, BucketEncryption, IBucket } from '@aws-cdk/aws-s3';
5-
import { Effect, Policy, PolicyDocument, PolicyStatement, Role, ServicePrincipal } from '@aws-cdk/aws-iam';
5+
import { AnyPrincipal, Effect, Policy, PolicyDocument, PolicyStatement, Role, ServicePrincipal } from '@aws-cdk/aws-iam';
66
import { Code, Function as LambdaFunction, Runtime } from '@aws-cdk/aws-lambda';
77

88
/**
@@ -77,14 +77,23 @@ export class CommonResourcesContruct extends Construct {
7777
});
7878
Tags.of(this.s3LogsBucket).add('SolutionId', props.solutionId);
7979

80+
this.s3LogsBucket.addToResourcePolicy(
81+
new PolicyStatement({
82+
actions: ['s3:*'],
83+
conditions: {
84+
Bool: { 'aws:SecureTransport': 'false' }
85+
},
86+
effect: Effect.DENY,
87+
principals: [new AnyPrincipal()],
88+
resources: [this.s3LogsBucket.bucketArn, this.s3LogsBucket.arnForObjects('*')]
89+
})
90+
);
91+
8092
const s3LogsBucketResource = this.s3LogsBucket.node.defaultChild as CfnResource;
8193
s3LogsBucketResource.addMetadata('cfn_nag', {
8294
rules_to_suppress: [{
8395
id: 'W35',
8496
reason: 'This is the logging bucket, it does not require logging.'
85-
}, {
86-
id: 'W51',
87-
reason: 'Since the bucket does not allow the public access, it does not require to have bucket policy.'
8897
}]
8998
})
9099

source/infrastructure/test/__snapshots__/common-resources.test.ts.snap

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ Object {
191191
"id": "W35",
192192
"reason": "This is the logging bucket, it does not require logging.",
193193
},
194-
Object {
195-
"id": "W51",
196-
"reason": "Since the bucket does not allow the public access, it does not require to have bucket policy.",
197-
},
198194
],
199195
},
200196
},
@@ -225,6 +221,53 @@ Object {
225221
"Type": "AWS::S3::Bucket",
226222
"UpdateReplacePolicy": "Retain",
227223
},
224+
"TestCommonResourcesLogsBucketPolicyAB18A08E": Object {
225+
"Properties": Object {
226+
"Bucket": Object {
227+
"Ref": "TestCommonResourcesLogsBucket5B4DBD4F",
228+
},
229+
"PolicyDocument": Object {
230+
"Statement": Array [
231+
Object {
232+
"Action": "s3:*",
233+
"Condition": Object {
234+
"Bool": Object {
235+
"aws:SecureTransport": "false",
236+
},
237+
},
238+
"Effect": "Deny",
239+
"Principal": Object {
240+
"AWS": "*",
241+
},
242+
"Resource": Array [
243+
Object {
244+
"Fn::GetAtt": Array [
245+
"TestCommonResourcesLogsBucket5B4DBD4F",
246+
"Arn",
247+
],
248+
},
249+
Object {
250+
"Fn::Join": Array [
251+
"",
252+
Array [
253+
Object {
254+
"Fn::GetAtt": Array [
255+
"TestCommonResourcesLogsBucket5B4DBD4F",
256+
"Arn",
257+
],
258+
},
259+
"/*",
260+
],
261+
],
262+
},
263+
],
264+
},
265+
],
266+
"Version": "2012-10-17",
267+
},
268+
},
269+
"Type": "AWS::S3::BucketPolicy",
270+
},
228271
"TestCommonResourcesUUIDFDB821D1": Object {
229272
"DeletionPolicy": "Delete",
230273
"Properties": Object {

source/infrastructure/test/__snapshots__/distributed-load-testing-on-aws-stack.test.ts.snap

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,10 +1968,6 @@ Object {
19681968
"id": "W35",
19691969
"reason": "This is the logging bucket, it does not require logging.",
19701970
},
1971-
Object {
1972-
"id": "W51",
1973-
"reason": "Since the bucket does not allow the public access, it does not require to have bucket policy.",
1974-
},
19751971
],
19761972
},
19771973
},
@@ -2008,6 +2004,53 @@ Object {
20082004
"Type": "AWS::S3::Bucket",
20092005
"UpdateReplacePolicy": "Retain",
20102006
},
2007+
"DLTCommonResourcesLogsBucketPolicyAA7FFB37": Object {
2008+
"Properties": Object {
2009+
"Bucket": Object {
2010+
"Ref": "DLTCommonResourcesLogsBucket48A2774D",
2011+
},
2012+
"PolicyDocument": Object {
2013+
"Statement": Array [
2014+
Object {
2015+
"Action": "s3:*",
2016+
"Condition": Object {
2017+
"Bool": Object {
2018+
"aws:SecureTransport": "false",
2019+
},
2020+
},
2021+
"Effect": "Deny",
2022+
"Principal": Object {
2023+
"AWS": "*",
2024+
},
2025+
"Resource": Array [
2026+
Object {
2027+
"Fn::GetAtt": Array [
2028+
"DLTCommonResourcesLogsBucket48A2774D",
2029+
"Arn",
2030+
],
2031+
},
2032+
Object {
2033+
"Fn::Join": Array [
2034+
"",
2035+
Array [
2036+
Object {
2037+
"Fn::GetAtt": Array [
2038+
"DLTCommonResourcesLogsBucket48A2774D",
2039+
"Arn",
2040+
],
2041+
},
2042+
"/*",
2043+
],
2044+
],
2045+
},
2046+
],
2047+
},
2048+
],
2049+
"Version": "2012-10-17",
2050+
},
2051+
},
2052+
"Type": "AWS::S3::BucketPolicy",
2053+
},
20112054
"DLTCommonResourcesUUID2FD025A2": Object {
20122055
"DeletionPolicy": "Delete",
20132056
"Properties": Object {

0 commit comments

Comments
 (0)