Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): hotswap doesn't update SSM parameter environment variables properly #26382

Merged
merged 6 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/util/cloudformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class CloudFormationStack {
if (!this.exists) { return {}; }
const ret: Record<string, string> = {};
for (const param of this.stack!.Parameters ?? []) {
ret[param.ParameterKey!] = param.ParameterValue!;
ret[param.ParameterKey!] = param.ResolvedValue ?? param.ParameterValue!;
}
return ret;
}
Expand Down
30 changes: 30 additions & 0 deletions packages/aws-cdk/test/api/deploy-stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,36 @@ test('correctly passes CFN parameters when hotswapping', async () => {
expect(tryHotswapDeployment).toHaveBeenCalledWith(expect.anything(), { A: 'A-value', B: 'B=value' }, expect.anything(), expect.anything(), HotswapMode.FALL_BACK);
});

test('correctly passes SSM parameters when hotswapping', async () => {
// GIVEN
givenStackExists({
Parameters: [
{ ParameterKey: 'SomeParameter', ParameterValue: 'ParameterName', ResolvedValue: 'SomeValue' },
],
});

// WHEN
await deployStack({
...standardDeployStackArguments(),
stack: testStack({
stackName: 'stack',
template: {
Parameters: {
SomeParameter: {
Type: 'AWS::SSM::Parameter::Value<String>',
Default: 'ParameterName',
},
},
},
}),
hotswap: HotswapMode.FALL_BACK,
usePreviousParameters: true,
});

// THEN
expect(tryHotswapDeployment).toHaveBeenCalledWith(expect.anything(), { SomeParameter: 'SomeValue' }, expect.anything(), expect.anything(), HotswapMode.FALL_BACK);
});

test('call CreateStack when method=direct and the stack doesnt exist yet', async () => {
// WHEN
await deployStack({
Expand Down