|
1 | 1 | # AWS Systems Manager Construct Library
|
2 | 2 |
|
3 |
| - |
4 | 3 | This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
|
5 | 4 |
|
6 | 5 | ## Using existing SSM Parameters in your CDK app
|
@@ -143,3 +142,32 @@ When specifying an `allowedPattern`, the values provided as string literals
|
143 | 142 | are validated against the pattern and an exception is raised if a value
|
144 | 143 | provided does not comply.
|
145 | 144 |
|
| 145 | +## Using Tokens in parameter name |
| 146 | + |
| 147 | +When using [CDK Tokens](https://docs.aws.amazon.com/cdk/v2/guide/tokens.html) in parameter name, |
| 148 | +you need to explicitly set the `simpleName` property. Setting `simpleName` to an incorrect boolean |
| 149 | +value may result in unexpected behaviours, such as having duplicate '/' in the parameter ARN |
| 150 | +or missing a '/' in the parameter ARN. |
| 151 | + |
| 152 | +`simpleName` is used to indicates whether the parameter name is a simple name. A parameter name |
| 153 | +without any '/' is considered a simple name, thus you should set `simpleName` to `true`. |
| 154 | +If the parameter name includes '/', set `simpleName` to `false`. |
| 155 | + |
| 156 | +```ts |
| 157 | +import * as lambda from 'aws-cdk-lib/aws-lambda'; |
| 158 | + |
| 159 | +const simpleParameter = new ssm.StringParameter(this, 'StringParameter', { |
| 160 | + // the parameter name doesn't contain any '/' |
| 161 | + parameterName: 'parameter', |
| 162 | + stringValue: 'SOME_VALUE', |
| 163 | + simpleName: true, // set `simpleName` to true |
| 164 | +}); |
| 165 | + |
| 166 | +declare const func: lambda.IFunction; |
| 167 | +const nonSimpleParameter = new ssm.StringParameter(this, 'StringParameter', { |
| 168 | + // the parameter name contains '/' |
| 169 | + parameterName: `/${func.functionName}/my/app/param`, |
| 170 | + stringValue: 'SOME_VALUE', |
| 171 | + simpleName: false, // set `simpleName` to false |
| 172 | +}); |
| 173 | +``` |
0 commit comments