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.



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

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.



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

def log_level
  @log_level
end

#screenshotsObject (readonly)

Returns the value of attribute screenshots.



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

def screenshots
  @screenshots
end

Instance Method Details

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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)


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

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



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

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



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

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



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

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 alternate contacts.' if resp
  resp
ensure
  browser.close rescue nil
end

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



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

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

#set_company_name(account_email:, account_password:, name:) ⇒ Object



158
159
160
161
162
163
164
# File 'lib/aws_account_utils.rb', line 158

def set_company_name(account_email:, account_password:, name:)
  resp = company_name.set , , name
  logger.info 'Set company name.' if resp
  resp
ensure
  browser.close rescue nil
end