Module: Smash::CloudPowers::Auth

Extended by:
Zenv
Included in:
Smash::CloudPowers, AwsResources, Node
Defined in:
lib/cloud_powers/auth.rb

Overview

Provides authentication to cloud resources, e.g. AWS

Class Method Summary collapse

Methods included from Zenv

env_vars, file_tree_search, i_vars, project_root, project_root=, system_vars, zfind

Methods included from Helpers

#create_logger, #log_file, #logger

Methods included from PathHelp

#job_exist?, #job_home, #job_path, #job_require_path

Methods included from LogicHelp

#attr_map, #called_from, #instance_attr_accessor, #smart_retry, #update_message_body

Methods included from LangHelp

#deep_modify_keys_with, #find_and_remove, #format_error_message, #from_json, #modify_keys_with, #to_basic_hash, #to_camel, #to_hyph, #to_i_var, #to_pascal, #to_ruby_file_name, #to_snake, #valid_json?, #valid_url?

Class Method Details

.credsObject

This method is usable before an object is instantiated in order to provide an Aws::Credentials object that will allow access to all the resources in the account that zfind searches for, using the ACCOUNT_NUMBER key.

Returns Aws::Credentials

Example

Auth.creds
=> Aws::Credentials # can be used to authenticate to AWS

Notes

  • This method relies on #zfind() to locate the key/secret strings

  • See Smash::CloudPowers::Zenv#zfind()



26
27
28
29
30
31
# File 'lib/cloud_powers/auth.rb', line 26

def self.creds
  @creds ||= Aws::Credentials.new(
    zfind(:aws_access_key_id),
    zfind(:aws_secret_access_key)
  )
end

.regionObject

This method is able to be called before an object is instantiated in order to provide a region in AWS-landia.

Returns The region set in configuration or a 'us-west-2' default String

Example

Auth.region
=> 'us-east-1'


42
43
44
# File 'lib/cloud_powers/auth.rb', line 42

def self.region
  zfind(:aws_region) || 'us-west-2'
end