Skip to content

Commit

Permalink
Don't specify SSM secure string parameter version when it is not supp…
Browse files Browse the repository at this point in the history
…lied

It is possible to omit the `version` of an SSM SecureString parameter.

When omitted, the reference generated by CDK results in a
ValidationError when applying the changes.

e.g.

```
Error [ValidationError]: Incorrect format is used in the following SSM reference: [{{resolve:ssm-secure:/some/parameter:}}]
```
  • Loading branch information
dglsparsons committed Sep 30, 2022
1 parent 3d227e5 commit add3a81
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-ssm/lib/parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,10 @@ export class StringParameter extends ParameterBase implements IStringParameter {
*/
public static fromSecureStringParameterAttributes(scope: Construct, id: string, attrs: SecureStringParameterAttributes): IStringParameter {
const version = attrs.version ? Tokenization.stringifyNumber(attrs.version) : '';
const stringValue = new CfnDynamicReference(CfnDynamicReferenceService.SSM_SECURE, `${attrs.parameterName}:${version}`).toString();
const stringValue = new CfnDynamicReference(
CfnDynamicReferenceService.SSM_SECURE,
version ? `${attrs.parameterName}:${version}` : attrs.parameterName,
).toString();

class Import extends ParameterBase {
public readonly parameterName = attrs.parameterName;
Expand Down

0 comments on commit add3a81

Please sign in to comment.