cloudhealth-setup 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/cloudhealth-setup.gemspec +1 -1
- data/lib/cht/mechanize.rb +52 -3
- data/lib/cht/policy.rb +1 -0
- data/lib/cloudhealth-accounts.csv +4 -0
- data/lib/cloudhealth-setup.rb +8 -1
- metadata +2 -1
data/cloudhealth-setup.gemspec
CHANGED
data/lib/cht/mechanize.rb
CHANGED
@@ -29,8 +29,31 @@ class Setup
|
|
29
29
|
puts "The login page returned error code #{login_page.code}"
|
30
30
|
raise SetupFailed, " Could not login to AWS Web Console, Amazon may be experiencing issues or the credentials you provided are incorrect. HTTP Code: #{login_page.code}"
|
31
31
|
end
|
32
|
+
|
33
|
+
# A Captcha can be present if they failed to login too many times, Lets detect it here.
|
34
|
+
captcha_form = login_page.form_with(:id => 'ap_signin_form')
|
35
|
+
unless captcha_form.nil?
|
36
|
+
captcha_on = captcha_form.field_with(:id => 'ap_captcha_guess')
|
37
|
+
unless captcha_on.nil?
|
38
|
+
raise SetupFailed, " Your account currently has a captcha on the login screen, This is most likely due to failed logins. Please login to your account at http://aws.amazon.com/ to stop the Captcha and then retry cloudhealth-setup."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
mfa_form = login_page.form_with(:id => 'ap_signin_form')
|
43
|
+
unless mfa_form.nil?
|
44
|
+
if @mfa.nil?
|
45
|
+
@mfa = ask("Multi-Factor Authentication detected, please enter 6 digit pin: ") do |q|
|
46
|
+
q.responses[:not_valid] = "You must enter a 6 digit MFA pin."
|
47
|
+
q.responses[:invalid_type] = "You must enter a 6 digit MFA pin."
|
48
|
+
q.validate = lambda {|p| p.length == 6 }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
mfa_form['tokenCode'] = @mfa
|
52
|
+
mfa_form.submit
|
53
|
+
end
|
32
54
|
end
|
33
55
|
|
56
|
+
|
34
57
|
account_id_search = page.search('//span[@class="txtxxsm"]/text()')
|
35
58
|
unless account_id_search.nil? || account_id_search.size == 0 || @created_account[:account_id]
|
36
59
|
firstw, secondw, account_id_long = account_id_search.first.content.strip.split(" ")
|
@@ -48,7 +71,10 @@ class Setup
|
|
48
71
|
|
49
72
|
page
|
50
73
|
rescue => e
|
51
|
-
|
74
|
+
#TODO: Fix when multi input account works
|
75
|
+
#raise SetupFailed, e
|
76
|
+
puts e
|
77
|
+
exit
|
52
78
|
end
|
53
79
|
end
|
54
80
|
|
@@ -184,11 +210,20 @@ class Setup
|
|
184
210
|
detailed_billing_form = page.form_with(:name=>'hourlyOptInForm')
|
185
211
|
bill_enabled = detailed_billing_form.field_with(:name => "buttonOptionHourly")
|
186
212
|
|
213
|
+
detailed_billing_tag_form = page.form_with(:name => 'hourlyWithResourcesAndTagsOptInForm')
|
214
|
+
tag_bill_enabled = detailed_billing_tag_form = detailed_billing_tag_form.field_with(:name => "buttonOptionHourlyWithResourcesAndTags")
|
215
|
+
|
187
216
|
if bill_enabled.value == "EnableHourly"
|
188
217
|
puts "[ ] Detailed billing report not setup -- Disabled"
|
189
218
|
elsif bill_enabled.value == "DisableHourly"
|
190
219
|
puts "[X] Detailed billing report setup -- Enabled"
|
191
220
|
end
|
221
|
+
|
222
|
+
if tag_bill_enabled.value == "EnableHourlyWithResourcesAndTags"
|
223
|
+
puts "[ ] Detailed billing report w/ tags & resources not setup -- Disabled"
|
224
|
+
elsif tag_bill_enabled.value == "DisableHourlyWithResourcesAndTags"
|
225
|
+
puts "[X] Detailed billing report w/ tags & resources setup -- Enabled"
|
226
|
+
end
|
192
227
|
rescue => e
|
193
228
|
puts " We were unable to test detailed billing reports."
|
194
229
|
puts " This setting can be enabled/tested manually under Billing Preferences from the AWS account page."
|
@@ -200,18 +235,32 @@ class Setup
|
|
200
235
|
begin
|
201
236
|
puts "Setting up detailed billing report..."
|
202
237
|
page = get_page
|
238
|
+
|
239
|
+
# This is the regular detailed billing report
|
203
240
|
detailed_billing_form = page.form_with(:name=>'hourlyOptInForm')
|
204
241
|
bill_enabled = detailed_billing_form.field_with(:name => "buttonOptionHourly")
|
205
242
|
|
243
|
+
# This is the detailed billing report with tags and resources
|
244
|
+
detailed_billing_tag_form = page.form_with(:name => 'hourlyWithResourcesAndTagsOptInForm')
|
245
|
+
tag_bill_enabled = detailed_billing_tag_form.field_with(:name => "buttonOptionHourlyWithResourcesAndTags")
|
246
|
+
|
206
247
|
if bill_enabled.value == "EnableHourly"
|
207
248
|
puts " Enabling detailed billing report... "
|
208
249
|
detailed_billing_form.submit
|
209
250
|
elsif bill_enabled.value == "DisableHourly"
|
210
|
-
puts "
|
251
|
+
puts " Detailed report already enabled... "
|
252
|
+
end
|
253
|
+
|
254
|
+
if tag_bill_enabled.value == "EnableHourlyWithResourcesAndTags"
|
255
|
+
puts " Enabling detailed billing report w/ tags & resources... "
|
256
|
+
detailed_billing_tag_form.submit
|
257
|
+
elsif tag_bill_enabled.value == "DisableHourlyWithResourcesAndTags"
|
258
|
+
puts " Detailed report w/ resources & tags already enabled... "
|
211
259
|
end
|
212
260
|
puts " Report setup finished"
|
261
|
+
|
213
262
|
rescue => e
|
214
|
-
puts "
|
263
|
+
puts " we were unable to enable detailed billing reports."
|
215
264
|
puts " This setting can be enabled manually under Billing Preferences from the AWS account page."
|
216
265
|
warning(e)
|
217
266
|
end
|
data/lib/cht/policy.rb
CHANGED
@@ -0,0 +1,4 @@
|
|
1
|
+
Account ID,Console URL,IAM Username,IAM Password,AWS Access Key,AWS Access Secret,S3 Bucket,Is Consolidated?
|
2
|
+
495052634639,https://495052634639.signin.aws.amazon.com/,some-new-aws-ro-user,576501261b83d6fd9203011822875fcc,AKIAJGMSIZUEXP2WLQWA,DgwWvYt0YaZrLw9AkRusWmjlrD5KDXAM5F4TqCwo,tst-mfa-3fweew,false
|
3
|
+
495052634639,https://495052634639.signin.aws.amazon.com/,some-new-aws-ro-user2,0251ee4449b2d65d8b3a220bb19b1eb3,AKIAIC7MUEK5XPLVDFVA,iapRZL97kafIJjpv/4W6qZotSaVggZaIri60gbVN,new-mfa-test-for-mejoshp,false
|
4
|
+
495052634639,https://495052634639.signin.aws.amazon.com/,some-new-aws-ro-user4,7830926c652bfb821607d71df9c2e200,AKIAIBVYS72XJNYDQWKA,jTOHuMUvChcdZhJDJn1p+9i9bGQvZYU9ItumsurU,tst-for-mfa,false
|
data/lib/cloudhealth-setup.rb
CHANGED
@@ -74,6 +74,11 @@ class MyCLI
|
|
74
74
|
:long => "--aws-secret SECRET",
|
75
75
|
:description => "AWS Secret"
|
76
76
|
|
77
|
+
option :multi_factor_code,
|
78
|
+
:short => "-m CODE",
|
79
|
+
:long => "--multi-factor CODE",
|
80
|
+
:description => "Multi-Factor Authentication Token / Code"
|
81
|
+
|
77
82
|
option :setup_bucket,
|
78
83
|
:short => "-b BUCKET",
|
79
84
|
:long => "--setup-billing-bucket BUCKET",
|
@@ -136,6 +141,7 @@ class Setup
|
|
136
141
|
@verbose = options[:verbose]
|
137
142
|
@overwrite_file = options[:overwrite_file]
|
138
143
|
@ro_user_exists = options[:ro_user_exists]
|
144
|
+
@mfa = options[:multi_factor_code] || nil
|
139
145
|
@created_account = {}
|
140
146
|
@iam = iam
|
141
147
|
@s3 = s3
|
@@ -180,7 +186,7 @@ class Setup
|
|
180
186
|
end
|
181
187
|
|
182
188
|
if input[:setup_bucket].nil?
|
183
|
-
output_opts[:setup_bucket] = ask("Input S3 Bucket name
|
189
|
+
output_opts[:setup_bucket] = ask("Input S3 Bucket name for billing: ")
|
184
190
|
end
|
185
191
|
|
186
192
|
output_opts
|
@@ -242,3 +248,4 @@ class Setup
|
|
242
248
|
Setup.write_csv(accounts_processed, cli.config[:output_file]) if ARGV[0] == "install"
|
243
249
|
end
|
244
250
|
end
|
251
|
+
Setup.run
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudhealth-setup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/cht/mechanize.rb
|
144
144
|
- lib/cht/output.rb
|
145
145
|
- lib/cht/policy.rb
|
146
|
+
- lib/cloudhealth-accounts.csv
|
146
147
|
- lib/cloudhealth-setup.rb
|
147
148
|
- cloudhealth-setup.gemspec
|
148
149
|
homepage: http://www.cloudhealthtech.com
|