Class Names
Functions for devising unique names for constructs.
Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Names : DeputyBase
Syntax (vb)
Public Class Names Inherits DeputyBase
Remarks
For example, those can be used to allocate unique physical names for resources.
Synopsis
Methods
| NodeUniqueId(Node) | Returns a CloudFormation-compatible unique identifier for a construct based on its path. |
| StackRelativeConstructPath(IConstruct) | Return the construct path of the given construct, starting at the nearest enclosing Stack. |
| UniqueId(IConstruct) | Returns a CloudFormation-compatible unique identifier for a construct based on its path. |
| UniqueResourceName(IConstruct, IUniqueResourceNameOptions) | Returns a CloudFormation-compatible unique identifier for a construct based on its path. |
Methods
NodeUniqueId(Node)
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
public static string NodeUniqueId(Node node)
Parameters
- node Node
The construct node.
Returns
a unique id based on the construct path
Remarks
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.
StackRelativeConstructPath(IConstruct)
Return the construct path of the given construct, starting at the nearest enclosing Stack.
public static string StackRelativeConstructPath(IConstruct construct)
Parameters
- construct IConstruct
Returns
Remarks
Skips over Nested Stacks, in other words Nested Stacks are included in the construct paths.
UniqueId(IConstruct)
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
public static string UniqueId(IConstruct construct)
Parameters
- construct IConstruct
The construct.
Returns
a unique id based on the construct path
Remarks
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().
UniqueResourceName(IConstruct, IUniqueResourceNameOptions)
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
public static string UniqueResourceName(IConstruct construct, IUniqueResourceNameOptions options)
Parameters
- construct IConstruct
The construct.
- options IUniqueResourceNameOptions
Options for defining the unique resource name.
Returns
a unique resource name based on the construct path
Remarks
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.