Skip to content

Commit 224dca6

Browse files
authored
Merge branch 'main' into app-asg-validation
2 parents f028a49 + a441d37 commit 224dca6

File tree

100 files changed

+40123
-57
lines changed

Some content is hidden

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

100 files changed

+40123
-57
lines changed

.github/workflows/repo-metrics.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
SEARCH_QUERY: 'repo:aws/aws-cdk is:issue created:${{ env.last_month }} -reason:"not planned"'
3737

3838
- name: Create report for issues
39-
uses: peter-evans/create-issue-from-file@v4
39+
uses: peter-evans/create-issue-from-file@v5
4040
with:
4141
title: Monthly issue metrics report
4242
token: ${{ secrets.GITHUB_TOKEN }}
@@ -50,7 +50,7 @@ jobs:
5050
SEARCH_QUERY: 'repo:aws/aws-cdk is:pr created:${{ env.last_month }} -is:draft'
5151

5252
- name: Create report for PRs
53-
uses: peter-evans/create-issue-from-file@v4
53+
uses: peter-evans/create-issue-from-file@v5
5454
with:
5555
title: Monthly PR metrics report
5656
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/request-cli-integ-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
persist-credentials: false
2020
- name: Find changed cli files
2121
id: changed-cli-files
22-
uses: tj-actions/changed-files@ae82ed4ae04587b665efad2f206578aa6f0e8539
22+
uses: tj-actions/changed-files@90a06d6ba9543371ab4df8eeca0be07ca6054959
2323
with:
2424
base_sha: ${{ github.event.pull_request.base.sha }}
2525
files_yaml: |

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ RELEASE_NOTES.md
5151

5252
# Produced by integ tests
5353
read*lock
54+
55+
# VSCode jest plugin
56+
.test-output
57+

packages/@aws-cdk-testing/framework-integ/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "cdk-lint",
1010
"pkglint": "pkglint -f",
1111
"test": "cdk-test",
12-
"integ": "integ-runner",
12+
"integ": "integ-runner --language javascript",
1313
"package": "cdk-package",
1414
"build+test": "yarn build && yarn test",
1515
"build+extract": "yarn build",

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.intrinsic-deletion-policy.js.snapshot/tree.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.nested-stacks.js.snapshot/tree.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/app-staging-synthesizer-alpha/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ const app = new App({
265265
});
266266
```
267267

268+
### Staging Bucket Encryption
269+
270+
By default, the staging resources will be stored in an S3 Bucket with KMS encryption. To use
271+
SSE-S3, set `stagingBucketEncryption` to `BucketEncryption.S3_MANAGED`.
272+
273+
```ts
274+
import { BucketEncryption } from 'aws-cdk-lib/aws-s3';
275+
276+
const app = new App({
277+
defaultStackSynthesizer: AppStagingSynthesizer.defaultResources({
278+
appId: 'my-app-id',
279+
stagingBucketEncryption: BucketEncryption.S3_MANAGED,
280+
}),
281+
});
282+
```
283+
268284
## Using a Custom Staging Stack per Environment
269285

270286
If you want to customize some behavior that is not configurable via properties,

packages/@aws-cdk/app-staging-synthesizer-alpha/lib/default-staging-stack.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ export interface DefaultStagingStackOptions {
6161
*/
6262
readonly stagingBucketName?: string;
6363

64+
/**
65+
* Encryption type for staging bucket
66+
*
67+
* @default - s3.BucketEncryption.KMS
68+
*/
69+
readonly stagingBucketEncryption?: s3.BucketEncryption;
70+
6471
/**
6572
* Pass in an existing role to be used as the file publishing role.
6673
*
@@ -219,6 +226,7 @@ export class DefaultStagingStack extends Stack implements IStagingResources {
219226

220227
private readonly appId: string;
221228
private readonly stagingBucketName?: string;
229+
private stagingBucketEncryption?: s3.BucketEncryption;
222230

223231
/**
224232
* File publish role ARN in asset manifest format
@@ -259,6 +267,7 @@ export class DefaultStagingStack extends Stack implements IStagingResources {
259267

260268
this.deployRoleArn = props.deployRoleArn;
261269
this.stagingBucketName = props.stagingBucketName;
270+
this.stagingBucketEncryption = props.stagingBucketEncryption;
262271
const specializer = new StringSpecializer(this, props.qualifier);
263272

264273
this.providedFileRole = props.fileAssetPublishingRole?._specialize(specializer);
@@ -358,7 +367,15 @@ export class DefaultStagingStack extends Stack implements IStagingResources {
358367
}
359368

360369
this.ensureFileRole();
361-
const key = this.createBucketKey();
370+
371+
let key = undefined;
372+
if (this.stagingBucketEncryption === s3.BucketEncryption.KMS || this.stagingBucketEncryption === undefined) {
373+
if (this.stagingBucketEncryption === undefined) {
374+
// default is KMS as an AWS best practice, and for backwards compatibility
375+
this.stagingBucketEncryption = s3.BucketEncryption.KMS;
376+
}
377+
key = this.createBucketKey();
378+
}
362379

363380
// Create the bucket once the dependencies have been created
364381
const bucket = new s3.Bucket(this, bucketId, {
@@ -369,7 +386,7 @@ export class DefaultStagingStack extends Stack implements IStagingResources {
369386
} : {
370387
removalPolicy: RemovalPolicy.RETAIN,
371388
}),
372-
encryption: s3.BucketEncryption.KMS,
389+
encryption: this.stagingBucketEncryption,
373390
encryptionKey: key,
374391

375392
// Many AWS account safety checkers will complain when buckets aren't versioned

packages/@aws-cdk/app-staging-synthesizer-alpha/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"watch": "cdk-watch",
4949
"lint": "cdk-lint",
5050
"test": "cdk-test",
51-
"integ": "integ-runner",
51+
"integ": "integ-runner --language javascript",
5252
"pkglint": "pkglint -f",
5353
"package": "cdk-package",
5454
"awslint": "cdk-awslint",

packages/@aws-cdk/app-staging-synthesizer-alpha/test/app-staging-synthesizer.test.ts

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from 'path';
33
import { App, Stack, CfnResource, FileAssetPackaging, Token, Lazy, Duration } from 'aws-cdk-lib';
44
import { Match, Template } from 'aws-cdk-lib/assertions';
55
import * as lambda from 'aws-cdk-lib/aws-lambda';
6+
import { BucketEncryption } from 'aws-cdk-lib/aws-s3';
67
import * as cxschema from 'aws-cdk-lib/cloud-assembly-schema';
78
import { CloudAssembly } from 'aws-cdk-lib/cx-api';
89
import { evaluateCFN } from './evaluate-cfn';
@@ -257,7 +258,7 @@ describe(AppStagingSynthesizer, () => {
257258
stack = new Stack(app, 'Stack', {
258259
env: {
259260
account: '000000000000',
260-
region: 'us-west-2',
261+
region: 'us-east-1',
261262
},
262263
});
263264
new CfnResource(stack, 'Resource', {
@@ -268,16 +269,60 @@ describe(AppStagingSynthesizer, () => {
268269
const asm = app.synth();
269270

270271
// THEN
271-
const stagingStackArtifact = asm.getStackArtifact(`StagingStack-${APP_ID}-000000000000-us-west-2`);
272-
273-
Template.fromJSON(stagingStackArtifact.template).hasResourceProperties('AWS::S3::Bucket', {
272+
Template.fromJSON(getStagingResourceStack(asm).template).hasResourceProperties('AWS::S3::Bucket', {
274273
LifecycleConfiguration: {
275274
Rules: Match.arrayWith([{
276275
ExpirationInDays: 1,
277276
Prefix: DEPLOY_TIME_PREFIX,
278277
Status: 'Enabled',
279278
}]),
280279
},
280+
// When stagingBucketEncryption is not specified, it should be KMS for backwards compatibility
281+
BucketEncryption: {
282+
ServerSideEncryptionConfiguration: [
283+
{
284+
ServerSideEncryptionByDefault: {
285+
SSEAlgorithm: 'aws:kms',
286+
},
287+
},
288+
],
289+
},
290+
});
291+
});
292+
293+
test('staging bucket with SSE-S3 encryption', () => {
294+
// GIVEN
295+
app = new App({
296+
defaultStackSynthesizer: AppStagingSynthesizer.defaultResources({
297+
appId: APP_ID,
298+
deployTimeFileAssetLifetime: Duration.days(1),
299+
stagingBucketEncryption: BucketEncryption.S3_MANAGED,
300+
}),
301+
});
302+
stack = new Stack(app, 'Stack', {
303+
env: {
304+
account: '000000000000',
305+
region: 'us-east-1',
306+
},
307+
});
308+
new CfnResource(stack, 'Resource', {
309+
type: 'Some::Resource',
310+
});
311+
312+
// WHEN
313+
const asm = app.synth();
314+
315+
// THEN
316+
Template.fromJSON(getStagingResourceStack(asm).template).hasResourceProperties('AWS::S3::Bucket', {
317+
BucketEncryption: {
318+
ServerSideEncryptionConfiguration: [
319+
{
320+
ServerSideEncryptionByDefault: {
321+
SSEAlgorithm: 'AES256',
322+
},
323+
},
324+
],
325+
},
281326
});
282327
});
283328
});

0 commit comments

Comments
 (0)