Class: AWSCDK::ARN

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ARN

Returns a new instance of ARN.

Raises:

  • (NoMethodError)


7
8
9
# File 'arn.rb', line 7

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

Class Method Details

.extract_resource_name(arn, resource_type) ⇒ String

Extract the full resource name from an ARN.

Necessary for resource names (paths) that may contain the separator, like arn:aws:iam::111111111111:role/path/to/role/name.

Only works if we statically know the expected resource_type beforehand, since we're going to use that to split the string on ':/' (and take the right-hand side).

We can't extract the 'resourceType' from the ARN at hand, because CloudFormation Expressions only allow literals in the 'separator' argument to { Fn::Split }, and so it can't be { Fn::Select: [5, { Fn::Split: [':', ARN] }}.

Only necessary for ARN formats for which the type-name separator is /.

Parameters:

  • arn (String)
  • resource_type (String)

Returns:

  • (String)


33
34
35
36
37
# File 'arn.rb', line 33

def self.extract_resource_name(arn, resource_type)
  Jsii::Type.check_type(arn, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "arn")
  Jsii::Type.check_type(resource_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "resourceType")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Arn", "extractResourceName", [arn, resource_type])
end

.format(components, stack = nil) ⇒ String

Creates an ARN from components.

If partition, region or account are not specified, the stack's partition, region and account will be used.

If any component is the empty string, an empty string will be inserted into the generated ARN at the location that component corresponds to.

The ARN will be formatted as follows:

arn:partition:service:region:account:resourcesepresource-name

The required ARN pieces that are omitted will be taken from the stack that the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope can be 'undefined'.

Parameters:

Returns:

  • (String)


58
59
60
61
62
63
# File 'arn.rb', line 58

def self.format(components, stack = nil)
  components = components.is_a?(Hash) ? ::AWSCDK::ARNComponents.new(**components.transform_keys(&:to_sym)) : components
  Jsii::Type.check_type(components, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bcm5Db21wb25lbnRzIn0=")), "components")
  Jsii::Type.check_type(stack, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TdGFjayJ9")), "stack") unless stack.nil?
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Arn", "format", [components, stack])
end

.jsii_overridable_methodsObject



11
12
13
14
# File 'arn.rb', line 11

def self.jsii_overridable_methods
  {
  }
end

.split(arn, arn_format) ⇒ AWSCDK::ARNComponents

Splits the provided ARN into its components.

Works both if 'arn' is a string like 'arn:aws:s3:::bucket', and a Token representing a dynamic CloudFormation expression (in which case the returned components will also be dynamic CloudFormation expressions, encoded as Tokens).

Parameters:

  • arn (String)

    the ARN to split into its components.

  • arn_format (AWSCDK::ARNFormat)

    the expected format of 'arn' - depends on what format the service 'arn' represents uses.

Returns:



75
76
77
78
79
# File 'arn.rb', line 75

def self.split(arn, arn_format)
  Jsii::Type.check_type(arn, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "arn")
  Jsii::Type.check_type(arn_format, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bcm5Gb3JtYXQifQ==")), "arnFormat")
  Jsii::Kernel.instance.call_static("aws-cdk-lib.Arn", "split", [arn, arn_format])
end