class Names
Language | Type name |
---|---|
.NET | Amazon.CDK.Names |
Go | github.com/aws/aws-cdk-go/awscdk/v2#Names |
Java | software.amazon.awscdk.Names |
Python | aws_cdk.Names |
TypeScript (source) | aws-cdk-lib » Names |
Functions for devising unique names for constructs.
For example, those can be used to allocate unique physical names for resources.
Methods
Name | Description |
---|---|
static node | Returns a CloudFormation-compatible unique identifier for a construct based on its path. |
static unique | Returns a CloudFormation-compatible unique identifier for a construct based on its path. |
static unique | Returns a CloudFormation-compatible unique identifier for a construct based on its path. |
UniqueId(node)
static nodepublic static nodeUniqueId(node: Node): string
Parameters
- node
Node
— The construct node.
Returns
string
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
The identifier includes a human readable portion rendered from the path components and a hash suffix.
TODO (v2): replace with API to use constructs.Node
.
Id(construct)
static uniquepublic static uniqueId(construct: IConstruct): string
Parameters
- construct
IConstruct
— The construct.
Returns
string
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
The identifier includes a human readable portion rendered from the path components and a hash suffix. uniqueId is not unique if multiple copies of the stack are deployed. Prefer using uniqueResourceName().
ResourceName(construct, options)
static uniquepublic static uniqueResourceName(construct: IConstruct, options: UniqueResourceNameOptions): string
Parameters
- construct
IConstruct
— The construct. - options
Unique
— Options for defining the unique resource name.Resource Name Options
Returns
string
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
This function finds the stackName of the parent stack (non-nested) to the construct, and the ids of the components in the construct path.
The user can define allowed special characters, a separator between the elements, and the maximum length of the resource name. The name includes a human readable portion rendered from the path components, with or without user defined separators, and a hash suffix. If the resource name is longer than the maximum length, it is trimmed in the middle.