Class: AWSCDK::Names
- Inherits:
-
Jsii::Object
- Object
- Jsii::Object
- AWSCDK::Names
- 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
- .jsii_overridable_methods ⇒ Object
-
.node_unique_id(node) ⇒ String
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
-
.stack_relative_construct_path(construct) ⇒ String
Return the construct path of the given construct, starting at the nearest enclosing Stack.
-
.unique_id(construct) ⇒ String
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
-
.unique_resource_name(construct, options) ⇒ String
Returns a CloudFormation-compatible unique identifier for a construct based on its path.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Names
constructor
A new instance of Names.
Constructor Details
#initialize(*args) ⇒ Names
Returns a new instance of Names.
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_methods ⇒ Object
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.
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.
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().
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.
72 73 74 75 76 77 |
# File 'names.rb', line 72 def self.unique_resource_name(construct, ) Jsii::Type.check_type(construct, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklDb25zdHJ1Y3QifQ==")), "construct") = .is_a?(Hash) ? ::AWSCDK::UniqueResourceNameOptions.new(**.transform_keys(&:to_sym)) : Jsii::Type.check_type(, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5VbmlxdWVSZXNvdXJjZU5hbWVPcHRpb25zIn0=")), "options") Jsii::Kernel.instance.call_static("aws-cdk-lib.Names", "uniqueResourceName", [construct, ]) end |