class Awspec::Type::Account

Constants

REMOVE_SUFFIX_RE

Public Instance Methods

account() click to toggle source
# File lib/awspec/type/account.rb, line 26
def account
  id
end
id() click to toggle source
# File lib/awspec/type/account.rb, line 22
def id
  @id ||= sts_client.get_caller_identity.account
end
lambda() click to toggle source
# File lib/awspec/type/account.rb, line 30
def lambda
  resource_via_client[:lambda]
end
method_missing(name) click to toggle source
Calls superclass method
# File lib/awspec/type/account.rb, line 34
def method_missing(name)
  name = name.to_s if name.instance_of?(Symbol)
  describe = name.tr('-', '_').to_sym
  super unless resource_via_client.members.include?(describe)
  resource_via_client[describe]
end
resource_via_client() click to toggle source
# File lib/awspec/type/account.rb, line 9
def resource_via_client
  attributes = sts_client.get_caller_identity.to_h
  Awspec::Helper::Type::ACCOUNT_ATTRIBUTES.each do |type|
    key = type.gsub(REMOVE_SUFFIX_RE, '').to_sym
    if key == 'ses'
      # https://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html
      next unless %w[us-east-1 us-west-2 eu-west-1].include?(Aws.config[:region])
    end
    eval "attributes[key] = Awspec::Type::#{type.camelize}.new.resource_via_client"
  end
  @resource_via_client ||= attributes.to_struct
end