pele 0.1.2.pre.pre → 0.1.4.pre.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pele/cli.rb +22 -29
- data/lib/pele/utils.rb +44 -0
- data/lib/pele/version.rb +1 -1
- data/lib/pele.rb +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f5082085364927e55779413b4d6c8d7b9525db1
|
4
|
+
data.tar.gz: 91cf7d70ba8882e64f910766fc8c1ec15a402178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 370a665eb0c5f916e951dc08c0c8471408cc7f62fab3812b0247048af04bc0d8562b01d18a702a84cf0b9e26185cb9fe8255aa409fca5f49fe24158d51213b6b
|
7
|
+
data.tar.gz: f08d6527d4ec2be7e2704489e85edc0f5c0f659a1d10a840672b252988a6d187a4a8215bdfb6148ce16ea50aa0cbe085285886c5871d7ad4c47e045878c5322a
|
data/lib/pele/cli.rb
CHANGED
@@ -3,41 +3,34 @@ module Pele
|
|
3
3
|
include Thor::Actions
|
4
4
|
|
5
5
|
desc 'pele init', 'Initializes the AWS credentials on your Machine'
|
6
|
+
|
6
7
|
def init
|
7
|
-
os =
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
os = Pele::Utils.get_os_path
|
9
|
+
prompt = TTY::Prompt.new active_color: :green
|
10
|
+
Pele::Utils.check_existing_file(os)
|
11
|
+
Pele.utils.post_identification
|
12
|
+
aws_access_key_id = prompt.ask('AWS Access Key ID: '.colorize(:blue), required: true)
|
13
|
+
aws_secret_access_key = prompt.ask('AWS Secret Access Key: '.colorize(:blue), required: true)
|
14
|
+
aws_region = prompt.select('Choose a AWS region: '.colorize(:blue), Pele::Regions::ALL)
|
15
|
+
if aws_access_key_id.empty? || aws_secret_access_key.empty? || aws_region.empty?
|
16
|
+
say('You need to provide all three credentials. Please try again', :red)
|
11
17
|
abort
|
12
18
|
end
|
13
|
-
|
14
|
-
|
15
|
-
overwrite = prompt.select("This is going to overwrite your existing #{'~/.aws/credentials'.colorize(:green)}. ok?", %w[OK EXIT])
|
16
|
-
abort unless overwrite == 'OK'
|
17
|
-
puts ' '
|
19
|
+
create_file os do
|
20
|
+
"[default]\naws_access_key_id = #{aws_access_key_id}\naws_secret_access_key = #{aws_secret_access_key}\nregion = #{aws_region}"
|
18
21
|
end
|
19
|
-
|
20
|
-
say('Your OS identified: ', :yellow)
|
21
|
-
puts ''
|
22
|
-
puts OS.report
|
22
|
+
say('Now lets generate AWS key-pair. This is needed to access EC2 Instances', :green)
|
23
23
|
puts ''
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
_aws_secret_access_key = prompt.ask('AWS Secret Access Key: '.colorize(:blue), required: true)
|
28
|
-
_aws_region = prompt.select('Choose a AWS region: '.colorize(:blue), Pele::Regions::ALL)
|
29
|
-
if _aws_access_key_id.empty? || _aws_secret_access_key.empty? || _aws_region.empty?
|
30
|
-
say('You need to provide all three credentials. Please try again', :red)
|
31
|
-
abort
|
24
|
+
if File.exist? File.expand_path "#{os}key"
|
25
|
+
overwrite = prompt.select('Looks like you already have a key generated. Would you like to generate new one?', %w[Yes No])
|
26
|
+
abort if overwrite == 'Yes'
|
32
27
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
"[default]\naws_access_key_id = #{_aws_access_key_id}\naws_secret_access_key = #{_aws_secret_access_key}\naws_region = #{_aws_region}"
|
40
|
-
end
|
28
|
+
puts ''
|
29
|
+
key_pair_name = prompt.ask('Name your key-pair. For example: mykeypair.colorize(:green)')
|
30
|
+
begin
|
31
|
+
Pele::Utils.create_key_pair(os, key_pair_name)
|
32
|
+
rescue
|
33
|
+
say('Something went wrong while trying to create key-pair. Please try again', :red)
|
41
34
|
end
|
42
35
|
end
|
43
36
|
end
|
data/lib/pele/utils.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Pele
|
2
|
+
module Utils
|
3
|
+
def get_os_path
|
4
|
+
if OS.windows?
|
5
|
+
'%USERPROFILE%.awscredentials'
|
6
|
+
elsif OS.mac? || OS.linux?
|
7
|
+
'~/.aws/credentials'
|
8
|
+
else
|
9
|
+
puts ''
|
10
|
+
say("Looks like we could not identify your OS.\n\nPlease setup your ENV values as follows:\n\nAWS_ACCESS_KEY_ID=[YOUR ACCES KEY ID]\nAWS_SECRET_ACCESS_KEY=[YOUR SECRET KEY ID]", :red)
|
11
|
+
abort
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_existing_file(os)
|
16
|
+
if File.exist? File.expand_path os
|
17
|
+
overwrite = prompt.select("This is going to overwrite your existing #{'~/.aws/credentials'.colorize(:green)}. ok?", %w[OK EXIT])
|
18
|
+
abort unless overwrite == 'OK'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def post_identification
|
23
|
+
puts "\e[H\e[2J"
|
24
|
+
say('Your OS identified: ', :yellow)
|
25
|
+
puts ''
|
26
|
+
puts OS.report
|
27
|
+
puts ''
|
28
|
+
say('Provide your aws credentials below', :yellow)
|
29
|
+
puts ''
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_key_pair(os, key_pair_name)
|
33
|
+
current_dirname = File.basename(Dir.getwd)
|
34
|
+
ec2 = Aws::EC2::Client.new
|
35
|
+
Dir.chdir File.dirname(os)
|
36
|
+
ec2.create_key_pair(key_name: key_pair_name)
|
37
|
+
Dir.chdir current_dirname
|
38
|
+
create_file "#{File.dirname(os)}key" do
|
39
|
+
key_pair_name.to_s
|
40
|
+
end
|
41
|
+
say('Key-pair successfully generated', :green)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/pele/version.rb
CHANGED
data/lib/pele.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pele
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4.pre.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suyesh Bhandari
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/pele.rb
|
127
127
|
- lib/pele/aws_regions.rb
|
128
128
|
- lib/pele/cli.rb
|
129
|
+
- lib/pele/utils.rb
|
129
130
|
- lib/pele/version.rb
|
130
131
|
- pele.gemspec
|
131
132
|
homepage: https://github.com/suyesh/pele
|