Names

class aws_cdk.Names(*args: Any, **kwargs)

Bases: object

Functions for devising unique names for constructs.

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

Static Methods

classmethod node_unique_id(node)

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.

Parameters:

node (Node) – The construct node.

Return type:

str

Returns:

a unique id based on the construct path

classmethod unique_id(construct)

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

Parameters:

construct (IConstruct) – The construct.

Return type:

str

Returns:

a unique id based on the construct path

classmethod unique_resource_name(construct, *, allowed_special_characters=None, max_length=None, separator=None)

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.

Parameters:
  • construct (IConstruct) – The construct.

  • allowed_special_characters (Optional[str]) – Non-alphanumeric characters allowed in the unique resource name. Default: - none

  • max_length (Union[int, float, None]) – The maximum length of the unique resource name. Default: - 256

  • separator (Optional[str]) – The separator used between the path components. Default: - none

Return type:

str

Returns:

a unique resource name based on the construct path