module Aws::ARNParser

def self.arn?(str)

Returns:
  • (Boolean) -

Parameters:
  • str (String) --
def self.arn?(str)
  !str.nil? && str.start_with?('arn:') && str.scan(/:/).length >= 5
end

def self.parse(arn_str)

Other tags:
    See: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-arns -

Returns:
  • (Aws::ARN) -

Parameters:
  • arn_str (String) --
def self.parse(arn_str)
  parts = arn_str.nil? ? [] : arn_str.split(':', 6)
  raise Aws::Errors::InvalidARNError if parts.size < 6
  # part[0] is "arn"
  arn = ARN.new(
    partition: parts[1],
    service: parts[2],
    region: parts[3],
    account_id: parts[4],
    resource: parts[5]
  )
  raise Aws::Errors::InvalidARNError unless arn.valid?
  arn
end