Skip to content

Commit

Permalink
fix(core): correctly reference versionless secure parameters (#18730)
Browse files Browse the repository at this point in the history
When no version is specified, the `:` at the end is not allowed.

Closes #18729.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
dbartholomae authored Jan 31, 2022
1 parent afdc550 commit 9f6e10e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/@aws-cdk/core/lib/secret-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ export class SecretValue extends Intrinsic {
* latest version of the parameter.
*/
public static ssmSecure(parameterName: string, version?: string): SecretValue {
const parts = [parameterName, version ?? ''];
return this.cfnDynamicReference(new CfnDynamicReference(CfnDynamicReferenceService.SSM_SECURE, parts.join(':')));
return this.cfnDynamicReference(
new CfnDynamicReference(CfnDynamicReferenceService.SSM_SECURE,
version ? `${parameterName}:${version}` : parameterName));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/core/test/secret-value.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('secret value', () => {
const v = SecretValue.ssmSecure('param-name');

// THEN
expect(stack.resolve(v)).toEqual('{{resolve:ssm-secure:param-name:}}');
expect(stack.resolve(v)).toEqual('{{resolve:ssm-secure:param-name}}');
});

test('cfnDynamicReference', () => {
Expand Down

0 comments on commit 9f6e10e

Please sign in to comment.