diff --git a/packages/aws-cdk-lib/aws-ssm/README.md b/packages/aws-cdk-lib/aws-ssm/README.md index e70e424f0573b..42cbb499dd90b 100644 --- a/packages/aws-cdk-lib/aws-ssm/README.md +++ b/packages/aws-cdk-lib/aws-ssm/README.md @@ -143,3 +143,31 @@ When specifying an `allowedPattern`, the values provided as string literals are validated against the pattern and an exception is raised if a value provided does not comply. +## Using Tokens in parameter name + +When using [CDK Tokens](https://docs.aws.amazon.com/cdk/v2/guide/tokens.html) in parameter name, +you need to explicitly set `simpleName` property. Setting `simpleName` to incorrect boolean +value may result in unexpected behaviours, such as getting duplicate '/' in the parameter ARN +or missing '/' in the parameter ARN. + +`simpleName` is used to indicates whether the parameter name is a simple name. A parameter name +without any '/' is considered a simple name, thus you should set `simpleName` to `true`. +If the parameter name includes '/', set `simpleName` to `false`. + +```ts +declare const func: lambda.IFunction; + +const simpleParameter = new ssm.StringParameter(this, 'StringParameter', { + // the parameter name is simple + parameterName: 'parameter', + stringValue: 'SOME_VALUE', + simpleName: true, // set `simpleName` to true +}); + +const nonSimpleParameter = new ssm.StringParameter(this, 'StringParameter', { + // the parameter name is not simple + parameterName: `/${func.functionName}/my/app/param`, + stringValue: 'SOME_VALUE', + simpleName: false, // set `simpleName` to false +}); +``` diff --git a/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts b/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts index 1972b605665fc..5b0e02ea13e47 100644 --- a/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts +++ b/packages/aws-cdk-lib/aws-ssm/lib/parameter.ts @@ -99,8 +99,10 @@ export interface ParameterOptions { readonly parameterName?: string; /** - * Indicates if the parameter name is a simple name (i.e. does not include "/" - * separators). + * Indicates whether the parameter name is a simple name. A parameter name + * without any "/" is considered a simple name. If the parameter name includes + * "/", setting simpleName to true might cause unintended issues, such + * as duplicate "/" in the resulting ARN. * * This is required only if `parameterName` is a token, which means we * are unable to detect if the name is simple or "path-like" for the purpose @@ -337,8 +339,10 @@ export interface CommonStringParameterAttributes { readonly parameterName: string; /** - * Indicates if the parameter name is a simple name (i.e. does not include "/" - * separators). + * Indicates whether the parameter name is a simple name. A parameter name + * without any "/" is considered a simple name. If the parameter name includes + * "/", setting simpleName to true might cause unintended issues, such + * as duplicate "/" in the resulting ARN. * * This is required only if `parameterName` is a token, which means we * are unable to detect if the name is simple or "path-like" for the purpose