Class: AWSCDK::Names

Inherits:
Jsii::Object
  • Object
show all
Defined in:
names.rb

Overview

Functions for devising unique names for constructs.

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Names

Returns a new instance of Names.

Raises:

  • (NoMethodError)


11
12
13
# File 'names.rb', line 11

def initialize(*args)
  raise NoMethodError, "aws-cdk-lib.Names does not have a visible constructor; use the provided factory methods"
end

Class Method Details

.jsii_overridable_methodsObject



15
16
17
18
# File 'names.rb', line 15

def self.jsii_overridable_methods
  {
  }
end

.node_unique_id(node) ⇒ 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.

Parameters:

  • node (Constructs::Node)

    The construct node.

Returns:

  • (String)

    a unique id based on the construct path



29
30
31
32
# File 'names.rb', line 29

def self.node_unique_id(node)
  Jsii::Type.check_type(node, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLk5vZGUifQ==")), "node")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Names", "nodeUniqueId", [node])
end

.stack_relative_construct_path(construct) ⇒ String

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.

Parameters:

  • construct (Constructs::IConstruct)

Returns:

  • (String)


41
42
43
44
# File 'names.rb', line 41

def self.stack_relative_construct_path(construct)
  Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "construct")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Names", "stackRelativeConstructPath", [construct])
end

.unique_id(construct) ⇒ 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().

Parameters:

  • construct (Constructs::IConstruct)

    The construct.

Returns:

  • (String)

    a unique id based on the construct path



54
55
56
57
# File 'names.rb', line 54

def self.unique_id(construct)
  Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "construct")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Names", "uniqueId", [construct])
end

.unique_resource_name(construct, options) ⇒ 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.

Parameters:

Returns:

  • (String)

    a unique resource name based on the construct path



72
73
74
75
76
77
# File 'names.rb', line 72

def self.unique_resource_name(construct, options)
  Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "construct")
  options = options.is_a?(Hash) ? ::AWSCDK::UniqueResourceNameOptions.new(**options.transform_keys(&:to_sym)) : options
  Jsii::Type.check_type(options, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5VbmlxdWVSZXNvdXJjZU5hbWVPcHRpb25zIn0=")), "options")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Names", "uniqueResourceName", [construct, options])
end