Skip to content
v2.274.0

Names Class ​

Functions for devising unique names for constructs.

For example, those can be used to allocate unique physical names for resources.

Methods ​

nodeUniqueId(node: Node): string@staticmethod def node_unique_id(node: Node) -> strpublic static String nodeUniqueId(Node node)public static string NodeUniqueId(Node node)func NodeUniqueId(Node Node) *stringstatic#
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.

1 parameter · returns

Parameters

  • nodenodenodenodeNode — The construct node.

Returns: a unique id based on the construct path

stackRelativeConstructPath(construct: IConstruct): string@staticmethod def stack_relative_construct_path(construct: IConstruct) -> strpublic static String stackRelativeConstructPath(IConstruct construct)public static string StackRelativeConstructPath(IConstruct construct)func StackRelativeConstructPath(Construct IConstruct) *stringstatic#
Return the construct path of the given construct, starting at the nearest enclosing Stack.

Skips over Nested Stacks, in other words Nested Stacks are included in the construct paths.

uniqueId(construct: IConstruct): string@staticmethod def unique_id(construct: IConstruct) -> strpublic static String uniqueId(IConstruct construct)public static string UniqueId(IConstruct construct)func UniqueId(Construct IConstruct) *stringstatic#
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().

1 parameter · returns

Parameters

  • constructconstructconstructconstructConstruct — The construct.

Returns: a unique id based on the construct path

uniqueResourceName(construct: IConstruct, options: UniqueResourceNameOptions): string@staticmethod def unique_resource_name(construct: IConstruct, options: UniqueResourceNameOptions) -> strpublic static String uniqueResourceName(IConstruct construct, UniqueResourceNameOptions options)public static string UniqueResourceName(IConstruct construct, UniqueResourceNameOptions options)func UniqueResourceName(Construct IConstruct, Options UniqueResourceNameOptions) *stringstatic#
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
notes · 2 parameters · returns

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.

Parameters

  • constructconstructconstructconstructConstruct — The construct.
  • optionsoptionsoptionsoptionsOptions — Options for defining the unique resource name.

Returns: a unique resource name based on the construct path