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(logger: nil, browser: nil, screenshots: nil) ⇒ AwsAccountUtils

Returns a new instance of AwsAccountUtils.



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

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

  Settings.set_screenshot_dir screenshots if screenshots
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#screenshotsObject (readonly)

Returns the value of attribute screenshots.



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

def screenshots
  @screenshots
end

Instance Method Details

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



47
48
49
50
51
52
53
# File 'lib/aws_account_utils.rb', line 47

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



39
40
41
42
43
44
45
# File 'lib/aws_account_utils.rb', line 39

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

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



55
56
57
58
59
60
61
# File 'lib/aws_account_utils.rb', line 55

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



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

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



63
64
65
66
67
68
69
# File 'lib/aws_account_utils.rb', line 63

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



71
72
73
74
75
76
77
# File 'lib/aws_account_utils.rb', line 71

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



79
80
81
82
83
84
85
# File 'lib/aws_account_utils.rb', line 79

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



87
88
89
90
91
92
93
# File 'lib/aws_account_utils.rb', line 87

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



95
96
97
98
99
100
101
# File 'lib/aws_account_utils.rb', line 95

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)


103
104
105
106
107
108
109
# File 'lib/aws_account_utils.rb', line 103

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



111
112
113
114
115
116
117
# File 'lib/aws_account_utils.rb', line 111

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



119
120
121
122
123
124
125
# File 'lib/aws_account_utils.rb', line 119

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



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

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



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

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