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

chore(ssm): update simple name description and documentation #30653

Merged
merged 7 commits into from
Jun 26, 2024
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
30 changes: 29 additions & 1 deletion packages/aws-cdk-lib/aws-ssm/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# AWS Systems Manager Construct Library


This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.

## Using existing SSM Parameters in your CDK app
Expand Down Expand Up @@ -143,3 +142,32 @@ 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 the `simpleName` property. Setting `simpleName` to an incorrect boolean
value may result in unexpected behaviours, such as having duplicate '/' in the parameter ARN
or missing a '/' 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
import * as lambda from 'aws-cdk-lib/aws-lambda';

const simpleParameter = new ssm.StringParameter(this, 'StringParameter', {
// the parameter name doesn't contain any '/'
parameterName: 'parameter',
stringValue: 'SOME_VALUE',
simpleName: true, // set `simpleName` to true
});

declare const func: lambda.IFunction;
const nonSimpleParameter = new ssm.StringParameter(this, 'StringParameter', {
// the parameter name contains '/'
parameterName: `/${func.functionName}/my/app/param`,
stringValue: 'SOME_VALUE',
simpleName: false, // set `simpleName` to false
});
```
12 changes: 8 additions & 4 deletions packages/aws-cdk-lib/aws-ssm/lib/parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading