elastip 0.2.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9dd3f880d8e89dab07acd9f68c31c2da2359ee90
4
- data.tar.gz: d2dd869e88ec10633aebe4fdf130a75eeaa996c5
3
+ metadata.gz: 71b572c3688c118ed0f3fac34c6ae818cc8d7067
4
+ data.tar.gz: 334a927e586c2df5c93455103416a7a767e34a32
5
5
  SHA512:
6
- metadata.gz: a5549e12870d9e5e779e04821f2bec2ad2b04581f5e3908f39ca55b1f92bc7124b51bd29aa152d0f0a88dc93f87ffe225201a79c7733889d8d04e77a8830dcb4
7
- data.tar.gz: c48758e9cc95231096bd18250fdd7247a4a249e6e76598d40f3976a256b24d17fc5027f15c1b3e253296fd8ab85ac8720d8cbab7485a1b9ef60cac7b8f28902f
6
+ metadata.gz: a137ed38d4163fc1bb73430e6eb70ab665d04dd7c6ac8d186378a529ca90fe224c45a2fbeecf98151acf3dd7166fb2b1a5c826e9128eac7b70e8029a95c2cb2e
7
+ data.tar.gz: '0118daa3fde71beeea16db8fbc7166596a5d55bab1475d8a29bc52fbeb6af5feb769051c1cde1a8743d802c16482576d83ac4f471860e62263bcb2ca8b57d4a6'
data/README.md CHANGED
@@ -40,6 +40,14 @@ $> elastip project_name production --all
40
40
  You got the idea. You can then use it directly in an alias doing `ssh ec2-user@$(elastip project-name production)`
41
41
 
42
42
 
43
+ ### Killing the inactive instances
44
+ ```
45
+ $> elastip project_name production --inactive --terminate
46
+ $>
47
+ ```
48
+
49
+ Careful with this one but it'll terminate all the instances marked as 'inactive' in their cname.
50
+
43
51
  ## Contributing
44
52
 
45
53
  Bug reports and pull requests are welcome on GitHub at https://github.com/pcboy/elastip. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/exe/elastip CHANGED
@@ -9,4 +9,8 @@ if !project or !env
9
9
  "Example: elastip 'my_pro*ect' production"
10
10
  end
11
11
 
12
- puts Elastip::Elastip.new(project, env, options).ip.join("\n")
12
+ if options.include?('--inactive')
13
+ puts Elastip::Elastip.new(project, env, all: options.include?('--all')).inactive_instances(terminate: options.include?('--terminate')).join("\n")
14
+ else
15
+ puts Elastip::Elastip.new(project, env, all: options.include?('--all')).ip.join("\n")
16
+ end
data/lib/elastip.rb CHANGED
@@ -5,17 +5,17 @@ require 'aws-sdk'
5
5
 
6
6
  module Elastip
7
7
  class Elastip
8
- def initialize(project, env, options=[])
8
+ def initialize(project, env, all: false)
9
9
  abort "You need to specify a project and an environnement (e.g staging,production)" if !project or !env
10
10
  @project_re = Regexp.new(project)
11
11
  @env = env
12
- @all = options.include?('--all')
12
+ @all = all
13
13
  end
14
14
 
15
15
  def ip
16
16
  active_envs = environments.map do |env|
17
- if @project_re =~ env[:application_name] && env[:environment_name].include?(@env)
18
- if @all || env[:health] == 'Green'
17
+ if @project_re =~ env[:application_name].downcase && env[:environment_name].include?(@env)
18
+ if @all || (env[:health] == 'Green' && env[:status] == 'Ready')
19
19
  env[:environment_name]
20
20
  end
21
21
  end
@@ -31,6 +31,25 @@ module Elastip
31
31
  target_instances.map{|x| x[:ip]}
32
32
  end
33
33
 
34
+ def inactive_instances(terminate: false)
35
+ inactive_envs = environments.map do |env|
36
+ if @project_re =~ env[:application_name].downcase && env[:environment_name].include?(@env)
37
+ if env[:cname] =~ /inactive/ && env[:status] == 'Ready'
38
+ env
39
+ end
40
+ end
41
+ end.compact
42
+
43
+ if terminate
44
+ inactive_envs.each do |env|
45
+ STDERR.puts "terminate: #{env[:environment_name]}"
46
+ ebs.terminate_environment(environment_name: env[:environment_name])
47
+ end
48
+ end
49
+
50
+ inactive_envs
51
+ end
52
+
34
53
  private
35
54
 
36
55
  def ebs
@@ -1,3 +1,3 @@
1
1
  module Elastip
2
- VERSION = "0.2.4"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pcboy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2018-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.6.13
138
+ rubygems_version: 2.6.14
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Elastip helps you find the ip addresses of your elastic beanstalk instances