Skip to content

Commit

Permalink
chore(cli): bootstrap stack is not termination protected by default (a…
Browse files Browse the repository at this point in the history
…ws#9058)

This adjusts the changes made here -
aws@0ec7912
- so as to not change the existing default behaviour of `cdk bootstrap`.

Customers can control this behaviour by running `cdk bootstrap` with the
flag `--termination-protection`.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
Niranjan Jayakar authored Jul 14, 2020
1 parent a17dc30 commit eb3a663
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/bootstrap/deploy-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function deployBootstrapStack(
environment: cxapi.EnvironmentUtils.format(environment.account, environment.region),
properties: {
templateFile,
terminationProtection: options.parameters?.terminationProtection ?? true,
terminationProtection: options.parameters?.terminationProtection ?? false,
},
});

Expand Down
10 changes: 5 additions & 5 deletions packages/aws-cdk/test/api/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,24 +262,24 @@ test('even if the bootstrap stack failed to create, can still retry bootstrappin
expect(cfnMocks.deleteStack).toHaveBeenCalled();
});

test('stacks are termination protected by default', async () => {
test('stack is not termination protected by default', async () => {
// WHEN
await bootstrapEnvironment(env, sdk);

// THEN
expect(executed).toBeTruthy();
expect(protectedTermination).toBeTruthy();
expect(protectedTermination).toBeFalsy();
});

test('termination protected is turned off when unset', async () => {
test('stack is termination protected when set', async () => {
// WHEN
await bootstrapEnvironment(env, sdk, {
parameters: {
terminationProtection: false,
terminationProtection: true,
},
});

// THEN
expect(executed).toBeTruthy();
expect(protectedTermination).toBeFalsy();
expect(protectedTermination).toBeTruthy();
});
10 changes: 5 additions & 5 deletions packages/aws-cdk/test/api/bootstrap2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,26 @@ describe('Bootstrapping v2', () => {
]);
});

test('stacks are termination protected by default', async () => {
test('stack is not termination protected by default', async () => {
await bootstrapEnvironment2(env, sdk);

expect(mockDeployStack).toHaveBeenCalledWith(expect.objectContaining({
stack: expect.objectContaining({
terminationProtection: true,
terminationProtection: false,
}),
}));
});

test('termination protected is turned off when unset', async () => {
test('stack is termination protected when option is set', async () => {
await bootstrapEnvironment2(env, sdk, {
parameters: {
terminationProtection: false,
terminationProtection: true,
},
});

expect(mockDeployStack).toHaveBeenCalledWith(expect.objectContaining({
stack: expect.objectContaining({
terminationProtection: false,
terminationProtection: true,
}),
}));
});
Expand Down

0 comments on commit eb3a663

Please sign in to comment.