Class: AwsAccountUtils::AwsAccountUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_account_utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log_level: :info, logger: nil, browser: nil, screenshots: nil) ⇒ AwsAccountUtils

Returns a new instance of AwsAccountUtils.



22
23
24
25
26
27
28
29
# File 'lib/aws_account_utils.rb', line 22

def initialize(log_level: :info, logger: nil, browser: nil, screenshots: nil)
  @log_level = log_level
  @logger = logger
  @browser = browser
  @screenshots = screenshots

  Settings.set_screenshot_dir screenshots if screenshots
end

Instance Attribute Details

#log_levelObject (readonly)

Returns the value of attribute log_level.



20
21
22
# File 'lib/aws_account_utils.rb', line 20

def log_level
  @log_level
end

#screenshotsObject (readonly)

Returns the value of attribute screenshots.



20
21
22
# File 'lib/aws_account_utils.rb', line 20

def screenshots
  @screenshots
end

Instance Method Details

#change_root_password(account_email:, account_password:, new_password:) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/aws_account_utils.rb', line 49

def change_root_password(account_email:, account_password:, new_password:)
  resp = password.change(, , new_password)
  logger.info 'Changed root password.' if resp
  resp
ensure
  browser.close rescue nil
end

#check_enterprise_support(account_email:, account_password:) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/aws_account_utils.rb', line 41

def check_enterprise_support(account_email:, account_password:)
  resp = enterprise_support.existing_support? , 
  logger.info 'Enterprise support was already enabled' if resp
  resp
ensure
  browser.close rescue nil
end

#close_account(account_email:, account_password:) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/aws_account_utils.rb', line 57

def (account_email:, account_password:)
  resp = .close(, )
  logger.info 'Closed Account.' if resp
  resp
ensure
  browser.close rescue nil
end

#confirm_consolidated_billing(account_email:, account_password:, confirmation_link:) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/aws_account_utils.rb', line 65

def confirm_consolidated_billing(account_email:, account_password:, confirmation_link:)
  resp = consolidated_billing.confirm , , confirmation_link
  logger.info 'Consolidated billing has been confirmed' if resp
  resp
ensure
  browser.close rescue nil
end

#create_account(account_name:, account_email:, account_password:, account_details:) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/aws_account_utils.rb', line 31

def (account_name:, account_email:, account_password:, account_details:)
  raise ArgumentError, "account_detials: must be a hash." unless .is_a?(Hash)
  . , , 
  resp = customer_information.submit , , 
  logger.info 'Successfully created account.' if resp
  resp
ensure
  browser.close rescue nil
end

#create_root_access_keys(account_email:, account_password:) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/aws_account_utils.rb', line 73

def create_root_access_keys(account_email:, account_password:)
  resp = root_access_keys.create , 
  logger.info 'Created root access keys.' if resp
  resp
ensure
  browser.close rescue nil
end

#delete_root_access_keys(account_email:, account_password:) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/aws_account_utils.rb', line 81

def delete_root_access_keys(account_email:, account_password:)
  resp = root_access_keys.delete , 
  logger.info 'Deleted all root access keys.' if resp
  resp
ensure
  browser.close rescue nil
end

#email_opt_out(account_email:, account_password:) ⇒ Object



89
90
91
92
93
94
95
# File 'lib/aws_account_utils.rb', line 89

def email_opt_out(account_email:, account_password:)
  resp = email_preferences.opt_out , 
  logger.info 'Successfully opted out of all emails' if resp
  resp
ensure
  browser.close rescue nil
end

#enable_enterprise_support(account_email:, account_password:) ⇒ Object



97
98
99
100
101
102
103
# File 'lib/aws_account_utils.rb', line 97

def enable_enterprise_support(account_email:, account_password:)
  resp = enterprise_support.enable , 
  logger.info 'Enabled enterprise support' if resp
  resp
ensure
  browser.close rescue nil
end

#enable_iam_billing(account_email:, account_password:) ⇒ Object



105
106
107
108
109
110
111
# File 'lib/aws_account_utils.rb', line 105

def enable_iam_billing(account_email:, account_password:)
  resp = iam_billing.enable , 
  logger.info 'Successfully enabled IAM billing' if resp
  resp
ensure
  browser.close rescue nil
end

#existing_consolidated_billing?(account_email:, account_password:) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
116
117
118
119
# File 'lib/aws_account_utils.rb', line 113

def existing_consolidated_billing?(account_email:, account_password:)
  resp = consolidated_billing.existing? , 
  logger.info 'Consolidated billing has already been setup' if resp
  resp
ensure
  browser.close rescue nil
end

#logout_from_consoleObject



121
122
123
124
125
126
127
# File 'lib/aws_account_utils.rb', line 121

def logout_from_console
  resp = logout.execute
  logger.info 'Logged out of console' if resp
  resp
ensure
  browser.close rescue nil
end

#request_consolidated_billing(master_account_email:, master_account_password:, account_email:) ⇒ Object



129
130
131
132
133
134
135
# File 'lib/aws_account_utils.rb', line 129

def request_consolidated_billing(master_account_email:, master_account_password:, account_email:)
  resp = consolidated_billing.request , , 
  logger.info 'Consolidated billing has been requested' if resp
  resp
ensure
  browser.close rescue nil
end

#set_alternate_contacts(account_email:, account_password:, contact_info:) ⇒ Object



147
148
149
150
151
152
153
154
155
# File 'lib/aws_account_utils.rb', line 147

def set_alternate_contacts(account_email:, account_password:, contact_info:)
  raise ArgumentError, "contact_info: must be a hash." unless contact_info.is_a?(Hash)

  resp = alternate_contacts.set , , contact_info
  logger.info 'Set alterante contacts.' if resp
  resp
ensure
  browser.close rescue nil
end

#set_challenge_questions(account_email:, account_password:, answers:) ⇒ Object



137
138
139
140
141
142
143
144
145
# File 'lib/aws_account_utils.rb', line 137

def set_challenge_questions(account_email:, account_password:, answers:)
  raise ArgumentError, "answers: must be a hash." unless answers.is_a?(Hash)

  resp = challenge_questions.create , , answers
  logger.info 'Security Challenge Questions have been setup' if resp
  resp
ensure
  browser.close rescue nil
end