aws_interactive_cli 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDc0OTVjODcxYzhlYzliNzg4YmNhMTQ0OTA3YWM0YTZkZmMxYWQ2OQ==
4
+ MzBiMmU5OTkxMWU5MWNkMDQ2NWUzNWQ5NGJlOWI0ZWYxNDFiNzEzYQ==
5
5
  data.tar.gz: !binary |-
6
- YzEwZDc2NGJiMDU4ODc4YTMxNGNmMTRkNjVkMjYxYjZmMmFkNTFiNg==
7
- !binary "U0hBNTEy":
6
+ NjRlOGQ3ODk0YTU4OGE1OGJkMzQ5YTM2YTYxMmYzN2FiNmU4OTA3ZQ==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- MDA5NDQxMTk1NjJlMDUzYzM0ZjFhYzdiNDA5MjcwOTQ3NThlNjE4YTQ1M2I3
10
- ZDY4ZmE1NTA5M2E5MTA5YWNjOWMxM2I3ZGY2YjNmYTg2NTFiZjBjODY1MjAw
11
- YmI0ZTE5MmIyNTBhMDYwNmMxMDQ2ZjcyNGQ3ODU2OGRlMWUzZGM=
9
+ NTk0MmFhMjVjZjkxZWRjMzAzOTA3MTk5ZDBmOGY3MDc1YTJjNGJjMzJhZTY5
10
+ ZWRkZjhjNDFmZTUxYTMwM2M3NDgwY2M0NjRkN2EzMWE0YzJlY2RhNWNlYmFl
11
+ MzM3ZmQ1ODM5ODQ1ZGIwOTExNDdmNTM5MTMwMmEyMWJhMDgxNmM=
12
12
  data.tar.gz: !binary |-
13
- Y2MyNWNjNmU4MGMwMjQyODIzMDNjODYzYzExMjQ4YTRkMDMzN2RlODk4MGVm
14
- NmVjMjEzMzM4NWNiNTFmNDRkNDhmOWE1ODY3YzE3YzdlMjkwNGFlMmRjZGU2
15
- MmNmOTllOTQwMWM4MzBlMTAxMzNjMzkzMGFjM2U3MmY1NGVlZWI=
13
+ ZmQ3MDgzOTQ2YTExODhmMTZlMTlkNmQ1NDM5ZGU2NmUzMTk5ZjFhZWNhZGM3
14
+ ZGY3NWVlMTQxZTk0YWY0NTViZjY5ZGVhNWY0NGRjNTFkNGYzNzJkMTVkODAy
15
+ ODRmMjA1YTAzOTdhNmQyYmZkYWViNTNmZjgzMzllMmUzMzA0ODg=
data/README.md CHANGED
@@ -1,24 +1,24 @@
1
- # Cthulhu
1
+ # AWSInteractiveCLI
2
2
 
3
- TODO: Write a gem description
3
+ #TODO Add Elastic Beanstalk Management
4
+ #TODO Terminate all "Daily" instances
5
+ #TODO Remove SSH if keypair is not given
4
6
 
5
7
  ## Installation
6
8
 
7
- Add this line to your application's Gemfile:
9
+ Run the following command to install the AWSInstanceCLI
8
10
 
9
- gem 'cthulhu'
11
+ gem install 'aws_interactive_cli'
10
12
 
11
- And then execute:
12
-
13
- $ bundle
13
+ ## Usage
14
14
 
15
- Or install it yourself as:
15
+ The first time you run the aws_interactive_cli the program checks for ~/.aws-config.yml. If the file is not found the program will ask for your access key, secret key, and the path to your keypair. Provided that you are executing this program on an instance and do not have access to your keypairs, the script will automatically disable the "SSH" functionality. All other functionality (should) still work.
16
16
 
17
- $ gem install cthulhu
17
+ Please report bugs you are seeing (or even better--debug them yourself), so this can become an easy, useful tool.
18
18
 
19
- ## Usage
19
+ Feedback and feature requests are welcome
20
20
 
21
- TODO: Write usage instructions here
21
+ Enjoy!
22
22
 
23
23
  ## Contributing
24
24
 
@@ -1,4 +1,4 @@
1
- # coding: utf-8
1
+ # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'aws_interactive_cli/version'
@@ -1,10 +1,15 @@
1
- #! /usr/bin/env ruby
2
-
3
- require 'configuration'
1
+ # require 'rubygems'
2
+ # require 'highline/import'
3
+ # # require 'aws-sdk'
4
+ # # require 'terminal-table'
5
+ # require '../lib/configuration'
4
6
  require 'base_methods'
7
+ # require '../lib/questions'
5
8
 
6
- configuration = StartingConfiguration.config
9
+ # Sets the Access Key, Secret key, and Keypair path
10
+ if configuration = StartingConfiguration.config
11
+ puts "config loaded"
12
+ end
7
13
 
8
14
  BaseMethods.start_over("none")
9
15
 
10
- exit
@@ -3,14 +3,10 @@
3
3
  # # require 'aws-sdk'
4
4
  # # require 'terminal-table'
5
5
  # require '../lib/configuration'
6
- require '../lib/base_methods'
6
+ require 'base_methods'
7
7
  # require '../lib/questions'
8
8
 
9
9
  # Sets the Access Key, Secret key, and Keypair path
10
10
  configuration = StartingConfiguration.config
11
11
 
12
12
  BaseMethods.start_over("none")
13
-
14
- #TODO Add Elastic Beanstalk Management
15
- #TODO Terminate all "Daily" instances
16
- #TODO Remove SSH if keypair is not given
@@ -1,3 +1,3 @@
1
1
  module AWSInteractiveCLI
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,9 @@
1
+ require 'rubygems'
2
+ require 'highline/import'
3
+ require 'terminal-table'
1
4
  require 'aws-sdk'
2
5
  require 'questions'
6
+ require 'configuration'
3
7
 
4
8
  class BaseMethods
5
9
 
@@ -7,13 +11,12 @@ class BaseMethods
7
11
  def self.describe_regions
8
12
  regions = AWS::Core::RegionCollection.new
9
13
  @array = []
10
- regions.each do | region |
11
- @array << region.name
12
- end
14
+ regions.each { |region| @array << region.name }
13
15
  end
14
16
 
15
17
  # Returns array of instances in specific region
16
18
  def self.describe_instance_by_region(region)
19
+ StartingConfiguration.config
17
20
  # TODO Refactor
18
21
  @instances = []
19
22
  client = AWS::EC2::Client.new(:region => region)
@@ -26,7 +29,7 @@ class BaseMethods
26
29
  @name = tag[:value]
27
30
  end
28
31
  end
29
-
32
+
30
33
  hash = {
31
34
  :instance_id => instance[:instances_set].first[:instance_id],
32
35
  :ip_address => instance[:instances_set].first[:ip_address],
@@ -38,7 +41,7 @@ class BaseMethods
38
41
  @tags.each do |tag|
39
42
  hash.merge!(tag)
40
43
  end
41
-
44
+
42
45
  @instances << hash
43
46
  end
44
47
  return @instances
@@ -60,19 +63,19 @@ class BaseMethods
60
63
  def self.start_over(region)
61
64
 
62
65
  question = Questions.new
66
+
67
+ # Start Process
68
+ if region == "none"
69
+ # Select a region
70
+ @region = question.region
71
+ else
72
+ @region = region
73
+ end
63
74
 
64
- # Start Process
65
- if region == "none"
66
- # Select a region
67
- @region = question.region
68
- else
69
- @region = region
70
- end
71
-
72
- # Select an Instance
73
- @selected_instance = question.select_instance(@region)
74
-
75
- # Select the action
76
- @instance = question.instance_action(@selected_instance)
75
+ # Select an Instance
76
+ @selected_instance = question.select_instance(@region)
77
+
78
+ # Select the action
79
+ @instance = question.instance_action(@selected_instance)
77
80
  end
78
81
  end
@@ -1,8 +1,3 @@
1
- require 'rubygems'
2
- require 'highline/import'
3
- require 'aws-sdk'
4
- require 'base_methods'
5
-
6
1
  class StartingConfiguration
7
2
 
8
3
  def self.config
@@ -10,15 +5,14 @@ class StartingConfiguration
10
5
  # Setting the Config file Location
11
6
  config_file = "#{Dir.home}/.aws-config.yml"
12
7
 
13
-
14
8
  unless File.file?(config_file)
15
9
  begin
16
10
  entry = Hash.new
17
11
 
18
12
  say("Configuration Details:")
19
13
 
20
- entry[:access_key] = ask("Access Key: ")
21
- entry[:secret_key] = ask("Secret Key: ")
14
+ entry[:access_key_id] = ask("Access Key: ")
15
+ entry[:secret_access_key] = ask("Secret Key: ")
22
16
  entry[:path_to_keypairs] = ask("Path to keypairs(/path/to/keypairs/): ")
23
17
 
24
18
  end
@@ -28,7 +22,6 @@ class StartingConfiguration
28
22
  end
29
23
 
30
24
  AWS.config(YAML.load(File.read(config_file)))
31
- hash = YAML.load(File.read(config_file))
32
25
 
33
26
  end
34
27
 
@@ -1,154 +1,146 @@
1
- require 'rubygems'
2
- require 'highline/import'
3
- require 'aws-sdk'
4
- require 'terminal-table'
5
- require 'configuration'
6
- require 'base_methods'
7
-
8
-
9
1
  class Questions
10
2
  def region
11
-
12
- #Select a region
13
- choose do |menu|
14
-
15
- menu.header= "Select a region"
16
-
17
- BaseMethods.describe_regions.each do | region |
18
- menu.choice(region){
19
- @@region = region
20
- return region
21
- }
22
- end
23
-
24
- menu.choice("Exit!"){
25
- exit
26
- }
27
- end
28
-
29
- end
3
+
4
+ #Select a region
5
+ choose do |menu|
30
6
 
31
- def select_instance(region)
32
- # Select an instance
33
- @instances = BaseMethods.describe_instance_by_region(region)
34
-
35
- choose do |menu|
36
- if @instances == []
37
- menu.prompt = "No instances in this region"
38
- else
39
- menu.prompt = "Select an instance"
40
-
41
- @instances.each do | instance |
42
-
43
- hash = {
44
- :instance_id => instance[:instance_id],
45
- :status => instance[:instance_state],
46
- :name => instance[:name],
47
- :launch_time => instance[:launch_time]
48
- }
49
-
50
- table = Terminal::Table.new :rows => hash
51
- menu.choice(table){
52
- table = Terminal::Table.new :rows => instance
53
- puts table
54
- @selected_instance = instance
7
+ menu.header= "Select a region"
8
+
9
+ BaseMethods.describe_regions.each do | region |
10
+ menu.choice(region){
11
+ @@region = region
12
+ return region
55
13
  }
56
14
  end
57
- end
58
- menu.choice("Change Regions"){
59
- BaseMethods.start_over("none")
60
- }
61
-
62
- menu.choice("Exit!"){
63
- exit
64
- }
65
- end
66
- end
67
15
 
68
- def instance_action(selected_instance)
69
- @selected_instance = selected_instance
70
- # Choose an Action
71
- choose do | menu |
72
-
73
- menu.prompt = "What would you like to do?"
74
- unless @selected_instance[:instance_state] == "stopped" || @selected_instance[:instance_state] == "terminated"
75
-
76
- #Sets @path_to_keypairs for access
77
- @path_to_keypairs = StartingConfiguration.path_to_keypair
78
- menu.choice("SSH"){
79
- system "ssh -i #{@path_to_keypairs}#{@selected_instance[:keypair]}.pem ec2-user@#{@selected_instance[:ip_address]}"
80
- BaseMethods.start_over(@@region)
16
+ menu.choice("Exit!"){
17
+ exit
81
18
  }
82
19
  end
83
- menu.choice("Refresh"){
84
- # Actually pull new data
85
- table = Terminal::Table.new :rows => @selected_instance
86
- puts table
87
- # Back to the beginning!
88
- self.instance_action(selected_instance)
89
- }
90
-
91
- if @selected_instance[:instance_state] == "running"
92
- menu.choice("Terminate"){
93
- choose do | menu2 |
94
- menu2.header = "Are you sure?"
95
-
96
- menu2.choice("Yes"){
97
- BaseMethods.instance_action(@selected_instance[:instance_id], "terminate", @@region)
98
- say("Instance #{@selected_instance[:instance_id]} has been TERMINATED")
99
- self.instance_action(selected_instance)
20
+
21
+ end
22
+
23
+ def select_instance(region)
24
+ # Select an instance
25
+ @instances = BaseMethods.describe_instance_by_region(region)
26
+
27
+ choose do |menu|
28
+ if @instances == []
29
+ menu.prompt = "No instances in this region"
30
+ else
31
+ menu.prompt = "Select an instance"
32
+
33
+ @instances.each do | instance |
34
+
35
+ hash = {
36
+ :instance_id => instance[:instance_id],
37
+ :status => instance[:instance_state],
38
+ :name => instance[:name],
39
+ :launch_time => instance[:launch_time]
100
40
  }
101
- menu2.choice("No"){
102
- self.instance_action(selected_instance)
41
+
42
+ table = Terminal::Table.new :rows => hash
43
+ menu.choice(table){
44
+ table = Terminal::Table.new :rows => instance
45
+ puts table
46
+ @selected_instance = instance
103
47
  }
104
48
  end
49
+ end
50
+ menu.choice("Change Regions"){
51
+ BaseMethods.start_over("none")
105
52
  }
106
- menu.choice("Stop"){
107
- choose do | menu2 |
108
- menu2.header = "Are you sure?"
109
- menu2.choice("Yes"){
110
- BaseMethods.instance_action(@selected_instance[:instance_id], "stop", @@region)
111
- say("Instance #{@selected_instance[:instance_id]} has been Stopped")
112
- self.instance_action(selected_instance)
113
- }
114
- menu2.choice("No"){
115
- self.instance_action(selected_instance)
116
- }
117
- end
53
+
54
+ menu.choice("Exit!"){
55
+ exit
118
56
  }
119
- elsif @selected_instance[:instance_state] == "stopped"
120
- menu.choice("Start"){
121
- BaseMethods.instance_action(@selected_instance[:instance_id], "start", @@region)
122
- say("Instance #{@selected_instance[:instance_id]} has been STARTED")
57
+ end
58
+ end
59
+
60
+ def instance_action(selected_instance)
61
+ @selected_instance = selected_instance
62
+ # Choose an Action
63
+ choose do | menu |
64
+
65
+ menu.prompt = "What would you like to do?"
66
+ unless @selected_instance[:instance_state] == "stopped" || @selected_instance[:instance_state] == "terminated"
67
+
68
+ #Sets @path_to_keypairs for access
69
+ @path_to_keypairs = StartingConfiguration.path_to_keypair
70
+ menu.choice("SSH"){
71
+ system "ssh -i #{@path_to_keypairs}#{@selected_instance[:keypair]}.pem ec2-user@#{@selected_instance[:ip_address]}"
72
+ BaseMethods.start_over(@@region)
73
+ }
74
+ end
75
+ menu.choice("Refresh"){
76
+ # Actually pull new data
77
+ table = Terminal::Table.new :rows => @selected_instance
78
+ puts table
79
+ # Back to the beginning!
123
80
  self.instance_action(selected_instance)
124
81
  }
125
- menu.choice("Terminate"){
126
- choose do | menu2 |
127
- menu2.header = "Are you sure?"
128
- menu2.choice("Yes"){
129
- BaseMethods.instance_action(@selected_instance[:instance_id], "terminate", @@region)
130
- say("Instance #{@selected_instance[:instance_id]} has been TERMINATED")
131
- self.instance_action(selected_instance)
132
- }
133
- menu2.choice("No"){
134
- puts "No action taken"
135
- self.instance_action(selected_instance)
136
- }
137
- end
82
+
83
+ if @selected_instance[:instance_state] == "running"
84
+ menu.choice("Terminate"){
85
+ choose do | menu2 |
86
+ menu2.header = "Are you sure?"
87
+
88
+ menu2.choice("Yes"){
89
+ BaseMethods.instance_action(@selected_instance[:instance_id], "terminate", @@region)
90
+ say("Instance #{@selected_instance[:instance_id]} has been TERMINATED")
91
+ self.instance_action(selected_instance)
92
+ }
93
+ menu2.choice("No"){
94
+ self.instance_action(selected_instance)
95
+ }
96
+ end
97
+ }
98
+ menu.choice("Stop"){
99
+ choose do | menu2 |
100
+ menu2.header = "Are you sure?"
101
+ menu2.choice("Yes"){
102
+ BaseMethods.instance_action(@selected_instance[:instance_id], "stop", @@region)
103
+ say("Instance #{@selected_instance[:instance_id]} has been Stopped")
104
+ self.instance_action(selected_instance)
105
+ }
106
+ menu2.choice("No"){
107
+ self.instance_action(selected_instance)
108
+ }
109
+ end
110
+ }
111
+ elsif @selected_instance[:instance_state] == "stopped"
112
+ menu.choice("Start"){
113
+ BaseMethods.instance_action(@selected_instance[:instance_id], "start", @@region)
114
+ say("Instance #{@selected_instance[:instance_id]} has been STARTED")
115
+ self.instance_action(selected_instance)
116
+ }
117
+ menu.choice("Terminate"){
118
+ choose do | menu2 |
119
+ menu2.header = "Are you sure?"
120
+ menu2.choice("Yes"){
121
+ BaseMethods.instance_action(@selected_instance[:instance_id], "terminate", @@region)
122
+ say("Instance #{@selected_instance[:instance_id]} has been TERMINATED")
123
+ self.instance_action(selected_instance)
124
+ }
125
+ menu2.choice("No"){
126
+ puts "No action taken"
127
+ self.instance_action(selected_instance)
128
+ }
129
+ end
130
+ }
131
+ end
132
+
133
+ menu.choice("Back to instances in #{@@region}"){
134
+ BaseMethods.start_over(@@region)
138
135
  }
139
- end
140
-
141
- menu.choice("Back to instances in #{@@region}"){
142
- BaseMethods.start_over(@@region)
143
- }
144
- menu.choice("Change Regions"){
145
- @@region=nil
146
- BaseMethods.start_over("none")
147
- }
148
-
149
- menu.choice("Exit!"){
150
- exit
151
- }
152
- end
153
- end
136
+ menu.choice("Change Regions"){
137
+ @@region=nil
138
+ BaseMethods.start_over("none")
139
+ }
140
+
141
+ menu.choice("Exit!"){
142
+ exit
143
+ }
144
+ end
145
+ end
154
146
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_interactive_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Ellis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-22 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.0.9
126
+ rubygems_version: 2.1.10
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: ! '["Easy way to start, stop, and ssh into instances"]'