Skip to content

Commit 6d78104

Browse files
author
Niranjan Jayakar
authored
Merge branch 'master' into nija-at/cognito-userpool-idp
2 parents a2a036e + 42d756d commit 6d78104

File tree

10 files changed

+36
-37
lines changed

10 files changed

+36
-37
lines changed

packages/@aws-cdk/assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"devDependencies": {
6666
"@aws-cdk/assert": "0.0.0",
6767
"@types/nodeunit": "^0.0.31",
68-
"@types/sinon": "^9.0.3",
68+
"@types/sinon": "^9.0.4",
6969
"aws-cdk": "0.0.0",
7070
"cdk-build-tools": "0.0.0",
7171
"cdk-integ-tools": "0.0.0",

packages/@aws-cdk/aws-lambda/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"@types/aws-lambda": "^8.10.39",
7171
"@types/lodash": "^4.14.153",
7272
"@types/nodeunit": "^0.0.31",
73-
"@types/sinon": "^9.0.3",
73+
"@types/sinon": "^9.0.4",
7474
"aws-sdk": "^2.681.0",
7575
"aws-sdk-mock": "^5.1.0",
7676
"cdk-build-tools": "0.0.0",

packages/@aws-cdk/aws-s3-assets/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"devDependencies": {
6262
"@aws-cdk/assert": "0.0.0",
6363
"@types/nodeunit": "^0.0.31",
64-
"@types/sinon": "^9.0.3",
64+
"@types/sinon": "^9.0.4",
6565
"aws-cdk": "0.0.0",
6666
"cdk-build-tools": "0.0.0",
6767
"cdk-integ-tools": "0.0.0",

packages/@aws-cdk/core/lib/size.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class Size {
2626
}
2727

2828
/**
29-
* Create a Storage representing an amount mebibytes.
29+
* Create a Storage representing an amount gibibytes.
3030
* 1 GiB = 1024 MiB
3131
*/
3232
public static gibibytes(amount: number): Size {
@@ -97,7 +97,7 @@ export class Size {
9797
}
9898

9999
/**
100-
* Rouding behaviour when converting between units of `Size`.
100+
* Rounding behaviour when converting between units of `Size`.
101101
*/
102102
export enum SizeRoundingBehavior {
103103
/** Fail the conversion if the result is not an integer. */

packages/@aws-cdk/custom-resources/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"@aws-cdk/aws-ssm": "0.0.0",
7474
"@types/aws-lambda": "^8.10.39",
7575
"@types/fs-extra": "^8.1.0",
76-
"@types/sinon": "^9.0.3",
76+
"@types/sinon": "^9.0.4",
7777
"aws-sdk": "^2.681.0",
7878
"aws-sdk-mock": "^5.1.0",
7979
"cdk-build-tools": "0.0.0",

packages/aws-cdk/lib/api/deploy-stack.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,17 @@ export async function deployStack(options: DeployStackOptions): Promise<DeploySt
235235
debug('Initiated creation of changeset: %s; waiting for it to finish creating...', changeSet.Id);
236236
const changeSetDescription = await waitForChangeSet(cfn, deployName, changeSetName);
237237

238+
// Update termination protection only if it has changed.
239+
const terminationProtection = stackArtifact.terminationProtection ?? false;
240+
if (!!cloudFormationStack.terminationProtection !== terminationProtection) {
241+
debug('Updating termination protection from %s to %s for stack %s', cloudFormationStack.terminationProtection, terminationProtection, deployName);
242+
await cfn.updateTerminationProtection({
243+
StackName: deployName,
244+
EnableTerminationProtection: terminationProtection,
245+
}).promise();
246+
debug('Termination protection updated to %s for stack %s', terminationProtection, deployName);
247+
}
248+
238249
if (changeSetHasNoChanges(changeSetDescription)) {
239250
debug('No changes are to be performed on %s.', deployName);
240251
await cfn.deleteChangeSet({ StackName: deployName, ChangeSetName: changeSetName }).promise();
@@ -262,17 +273,6 @@ export async function deployStack(options: DeployStackOptions): Promise<DeploySt
262273
print('Changeset %s created and waiting in review for manual execution (--no-execute)', changeSetName);
263274
}
264275

265-
// Update termination protection only if it has changed.
266-
const terminationProtection = stackArtifact.terminationProtection ?? false;
267-
if (cloudFormationStack.terminationProtection !== terminationProtection) {
268-
debug('Updating termination protection from %s to %s for stack %s', cloudFormationStack.terminationProtection, terminationProtection, deployName);
269-
await cfn.updateTerminationProtection({
270-
StackName: deployName,
271-
EnableTerminationProtection: terminationProtection,
272-
}).promise();
273-
debug('Termination protection updated to %s for stack %s', terminationProtection, deployName);
274-
}
275-
276276
return { noOp: false, outputs: cloudFormationStack.outputs, stackArn: changeSet.StackId!, stackArtifact };
277277
}
278278

@@ -399,8 +399,7 @@ async function canSkipDeploy(deployStackOptions: DeployStackOptions, cloudFormat
399399
}
400400

401401
// Termination protection has been updated
402-
const terminationProtection = deployStackOptions.stack.terminationProtection ?? false; // cast to boolean for comparison
403-
if (terminationProtection !== cloudFormationStack.terminationProtection) {
402+
if (!!deployStackOptions.stack.terminationProtection !== !!cloudFormationStack.terminationProtection) {
404403
debug(`${deployName}: termination protection has been updated`);
405404
return false;
406405
}

packages/aws-cdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@types/node": "^10.17.21",
5151
"@types/promptly": "^3.0.0",
5252
"@types/semver": "^7.2.0",
53-
"@types/sinon": "^9.0.3",
53+
"@types/sinon": "^9.0.4",
5454
"@types/table": "^4.0.7",
5555
"@types/uuid": "^8.0.0",
5656
"@types/yaml": "^1.9.7",

packages/aws-cdk/test/integ/cli/app/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ new StackWithNestedStack(app, `${stackPrefix}-with-nested-stack`);
280280
new StackWithNestedStackUsingParameters(app, `${stackPrefix}-with-nested-stack-using-parameters`);
281281

282282
new YourStack(app, `${stackPrefix}-termination-protection`, {
283-
terminationProtection: true,
283+
terminationProtection: process.env.TERMINATION_PROTECTION !== 'FALSE' ? true : false,
284284
});
285285

286286
app.synth();

packages/aws-cdk/test/integ/cli/cli.integtest.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ test('Two ways of shoing the version', async () => {
3939
});
4040

4141
test('Termination protection', async () => {
42-
await cdkDeploy('termination-protection');
42+
const stackName = 'termination-protection';
43+
await cdkDeploy(stackName);
4344

4445
// Try a destroy that should fail
45-
await expect(cdkDestroy('termination-protection')).rejects.toThrow('exited with error');
46+
await expect(cdkDestroy(stackName)).rejects.toThrow('exited with error');
4647

47-
await cloudFormation('updateTerminationProtection', {
48-
EnableTerminationProtection: false,
49-
StackName: fullStackName('termination-protection'),
50-
});
48+
// Can update termination protection even though the change set doesn't contain changes
49+
await cdkDeploy(stackName, { modEnv: { TERMINATION_PROTECTION: 'FALSE' } });
50+
await cdkDestroy(stackName);
5151
});
5252

5353
test('cdk synth', async () => {
@@ -437,15 +437,15 @@ test('IAM diff', async () => {
437437

438438
// Roughly check for a table like this:
439439
//
440-
// ┌───┬─────────────────┬────────┬────────────────┬────────────────────────────┬───────────┐
441-
// │ │ Resource │ Effect │ Action │ Principal │ Condition │
442-
// ├───┼─────────────────┼────────┼────────────────┼────────────────────────────┼───────────┤
443-
// │ + │ ${SomeRole.Arn} │ Allow │ sts:AssumeRole │ Service:ec2.amazonaws.com │ │
444-
// └───┴─────────────────┴────────┴────────────────┴────────────────────────────┴───────────┘
440+
// ┌───┬─────────────────┬────────┬────────────────┬────────────────────────────-──┬───────────┐
441+
// │ │ Resource │ Effect │ Action │ Principal │ Condition │
442+
// ├───┼─────────────────┼────────┼────────────────┼───────────────────────────────┼───────────┤
443+
// │ + │ ${SomeRole.Arn} │ Allow │ sts:AssumeRole │ Service:ec2.${AWS::URLSuffix} │ │
444+
// └───┴─────────────────┴────────┴────────────────┴───────────────────────────────┴───────────┘
445445

446446
expect(output).toContain('${SomeRole.Arn}');
447447
expect(output).toContain('sts:AssumeRole');
448-
expect(output).toContain('ec2.amazonaws.com');
448+
expect(output).toContain('ec2.${AWS::URLSuffix}');
449449
});
450450

451451
test('fast deploy', async () => {

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1595,10 +1595,10 @@
15951595
dependencies:
15961596
"@types/node" "*"
15971597

1598-
"@types/sinon@^9.0.3":
1599-
version "9.0.3"
1600-
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-9.0.3.tgz#c803f2ebf96db44230ce4e632235c279830edd45"
1601-
integrity sha512-NWVG++603tEDwmz5k0DwFR1hqP3iBmq5GYi6d+0KCQMQsfDEULF1D7xqZ+iXRJHeGwLVhM+Rv73uzIYuIUVlJQ==
1598+
"@types/sinon@^9.0.4":
1599+
version "9.0.4"
1600+
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-9.0.4.tgz#e934f904606632287a6e7f7ab0ce3f08a0dad4b1"
1601+
integrity sha512-sJmb32asJZY6Z2u09bl0G2wglSxDlROlAejCjsnor+LzBMz17gu8IU7vKC/vWDnv9zEq2wqADHVXFjf4eE8Gdw==
16021602
dependencies:
16031603
"@types/sinonjs__fake-timers" "*"
16041604

0 commit comments

Comments
 (0)