# Names

Functions for devising unique names for constructs.

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

- Source: [`core/lib/names.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/core/lib/names.ts#L40)
- Type last changed: v2.187.0 · 31 Mar 2025

## Methods

- `nodeUniqueId(node: Node): string` (static) — 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` — The construct node.

  **Returns:** a unique id based on the construct path

- `stackRelativeConstructPath(construct: IConstruct): string` (static) — 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` (static) — 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` — The construct.

  **Returns:** a unique id based on the construct path

- `uniqueResourceName(construct: IConstruct, options: UniqueResourceNameOptions): string` (static) — 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` — The construct.
  - `options` — Options for defining the unique resource name.

  **Returns:** a unique resource name based on the construct path
