aws-cdk-lib.Names

class Names

LanguageType name
.NETAmazon.CDK.Names
Gogithub.com/aws/aws-cdk-go/awscdk/v2#Names
Javasoftware.amazon.awscdk.Names
Pythonaws_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

NameDescription
static nodeUniqueId(node)Returns a CloudFormation-compatible unique identifier for a construct based on its path.
static uniqueId(construct)Returns a CloudFormation-compatible unique identifier for a construct based on its path.
static uniqueResourceName(construct, options)Returns a CloudFormation-compatible unique identifier for a construct based on its path.

static nodeUniqueId(node)

public 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.


static uniqueId(construct)

public 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().


static uniqueResourceName(construct, options)

public static uniqueResourceName(construct: IConstruct, options: UniqueResourceNameOptions): string

Parameters

  • construct IConstruct — The construct.
  • options UniqueResourceNameOptions — Options for defining the unique resource name.

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.