knife-ec2find 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/LICENSE +13 -0
- data/README.md +2 -0
- data/knife-ec2find.gemspec +26 -0
- data/lib/chef/knife/ec2_find_acl.rb +48 -0
- data/lib/chef/knife/ec2_find_base.rb +67 -0
- data/lib/chef/knife/ec2_find_cgw.rb +48 -0
- data/lib/chef/knife/ec2_find_igw.rb +48 -0
- data/lib/chef/knife/ec2_find_image.rb +48 -0
- data/lib/chef/knife/ec2_find_instance.rb +53 -0
- data/lib/chef/knife/ec2_find_rtb.rb +48 -0
- data/lib/chef/knife/ec2_find_sg.rb +50 -0
- data/lib/chef/knife/ec2_find_subnet.rb +48 -0
- data/lib/chef/knife/ec2_find_vpc.rb +48 -0
- data/lib/knife-ec2find/version.rb +6 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: abd8cd015cdd41505f84ec426c045edd922e2cf7
|
4
|
+
data.tar.gz: 53465cce26bb3b38c684ed777379902333790e6c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ddc07fc27d79a20bc134fd44e664cfab6af1712a5e9e245e21d9ff3afcf2824f474e8748588df29947c9a4a5ab9455834bcbbd8f3218eccab5aaab4cbe0d6b59
|
7
|
+
data.tar.gz: 06b11205ec2adb41bf60d99d3d8febae80eb857b28d789596dbbe65fd8dba65c04add4ba5445f9e37a17f1a517d778976b434fc38538f7976ee8fcd75de7e99b
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.idea
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2015 Mikhail Advani
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "knife-ec2find/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "knife-ec2find"
|
7
|
+
s.version = Knife::EC2Find::VERSION
|
8
|
+
s.has_rdoc = true
|
9
|
+
s.authors = ["Mikhail Advani"]
|
10
|
+
s.email = ["mikhail.advani@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/mikhailadvani/knife-ec2find"
|
12
|
+
s.summary = "AWS resource finder by tags using knife"
|
13
|
+
s.description = "Referencing of resources needs to be done by ids but the only controlled attributes are tags. This is a knife plugin to help you get the id using tags"
|
14
|
+
s.license = "Apache"
|
15
|
+
s.extra_rdoc_files = ["LICENSE" ]
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.add_dependency "aws-sdk", "~> 2.0"
|
21
|
+
s.add_dependency "chef", "~> 12.5"
|
22
|
+
|
23
|
+
%w(rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
|
24
|
+
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findAcl < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find acl TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["network_acl_id","vpc_id", "is_default", "entries", "associations", "tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
@ec2client.describe_network_acls({dry_run: false, filters: tags}).network_acls
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'chef/knife'
|
2
|
+
require 'aws-sdk'
|
3
|
+
|
4
|
+
module EC2Find
|
5
|
+
class Ec2findBase < Chef::Knife
|
6
|
+
|
7
|
+
def run
|
8
|
+
@region = config[:region] || ENV["AWS_REGION"]
|
9
|
+
@access_key_id = config[:aws_access_key_id] || ENV["AWS_ACCESS_KEY_ID"]
|
10
|
+
@secret_access_key = config[:aws_secret_access_key] || ENV["AWS_SECRET_ACCESS_KEY"]
|
11
|
+
if validated?
|
12
|
+
resources = findby tag_filters
|
13
|
+
resources.each do |resource|
|
14
|
+
if config[:projection]
|
15
|
+
print_description resource, config[:projection].split(",")
|
16
|
+
else
|
17
|
+
print_description resource
|
18
|
+
end
|
19
|
+
end
|
20
|
+
ui.msg("#{resources.size} resource(s) found") unless config[:suppress_attribute_names]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def print_description resource, attributes=default_attributes
|
27
|
+
begin
|
28
|
+
attributes.each do |attribute|
|
29
|
+
unless config[:suppress_attribute_names]
|
30
|
+
puts "#{attribute}\t#{resource.send(attribute)}"
|
31
|
+
else
|
32
|
+
puts "#{resource.send(attribute)}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
rescue Exception => e
|
36
|
+
ui.error("Please check the attribute name(s) needed")
|
37
|
+
exit(1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def validated?
|
42
|
+
ui.error("Please provide region") if @region.nil?
|
43
|
+
ui.error("Please provide access key id") if @access_key_id.nil?
|
44
|
+
ui.error("Please provide secret access key") if @secret_access_key.nil?
|
45
|
+
ui.error("Please specify the selector tags") if config[:tags].nil?
|
46
|
+
!@region.nil? && !@access_key_id.nil? && !@secret_access_key.nil? && !config[:tags].nil?
|
47
|
+
end
|
48
|
+
|
49
|
+
def tag_filters
|
50
|
+
tags = []
|
51
|
+
config[:tags].split(",").each do |tag|
|
52
|
+
key, value = tag.split("=")
|
53
|
+
tags << {name: "tag:#{key}", values: [value]}
|
54
|
+
end
|
55
|
+
tags
|
56
|
+
end
|
57
|
+
|
58
|
+
def ec2connect
|
59
|
+
begin
|
60
|
+
@ec2client = Aws::EC2::Client.new(access_key_id: @access_key_id, secret_access_key: @secret_access_key, region: @region)
|
61
|
+
rescue Exception => e
|
62
|
+
ui.error(e.message)
|
63
|
+
exit(1)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findCgw < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find cgw TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["customer_gateway_id", "state", "type", "ip_address", "bgp_asn", "tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
@ec2client.describe_customer_gateways({dry_run: false, filters: tags}).customer_gateways
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findIgw < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find igw TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["internet_gateway_id", "attachments", "tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
@ec2client.describe_internet_gateways({dry_run: false, filters: tags}).internet_gateways
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findImage < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find image TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["image_id", "image_location", "state", "public", "architecture", "image_type", "platform", "name", "description", "root_device_type", "virtualization_type", "hypervisor", "tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
@ec2client.describe_images({dry_run: false, filters: tags}).images
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findInstance < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find instance TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["instance_id", "image_id", "key_name", "subnet_id", "vpc_id", "private_ip_address", "public_ip_address", "tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
reservation = @ec2client.describe_instances({dry_run: false, filters: tags}).reservations[0]
|
45
|
+
if reservation.nil?
|
46
|
+
[]
|
47
|
+
else
|
48
|
+
reservation.instances
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findRtb < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find rtb TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["route_table_id","vpc_id","routes","associations","tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
@ec2client.describe_route_tables({dry_run: false, filters: tags}).route_tables
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findSg< Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find sg TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["group_name","group_id","description","ip_permissions","ip_permissions_egress","vpc_id","tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
x = @ec2client.describe_security_groups({dry_run: false, filters: tags}).security_groups
|
45
|
+
puts x.inspect
|
46
|
+
x
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findSubnet < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find subnet TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["subnet_id","vpc_id","availability_zone","cidr_block","default_for_az","tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
@ec2client.describe_subnets({dry_run: false, filters: tags}).subnets
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative 'ec2_find_base'
|
2
|
+
module EC2Find
|
3
|
+
class Ec2findVpc < Ec2findBase
|
4
|
+
|
5
|
+
banner "knife ec2find vpc TAGS"
|
6
|
+
|
7
|
+
option :tags,
|
8
|
+
:short => "-T T=V[,T=V[,T=V...]]",
|
9
|
+
:long => "--tags Tag=Value[,Tag=Value[,Tag=Value...]]",
|
10
|
+
:description => "Lists instances created with set of tags"
|
11
|
+
|
12
|
+
option :aws_access_key_id,
|
13
|
+
:long => "--aws-access-key-id KEY",
|
14
|
+
:description => "Your AWS Access Key ID(fallback to environment variable - AWS_ACCESS_KEY_ID)"
|
15
|
+
|
16
|
+
option :aws_secret_access_key,
|
17
|
+
:short => "-K SECRET",
|
18
|
+
:long => "--aws-secret-access-key",
|
19
|
+
:description => "Your AWS API Secret Access Key(fallback to environment variable - AWS_SECRET_ACCESS_KEY)"
|
20
|
+
|
21
|
+
option :region,
|
22
|
+
:long => "--region REGION",
|
23
|
+
:description => "AWS Region your VPC is hosted in(fallback to environment variable - AWS_REGION)"
|
24
|
+
|
25
|
+
option :projection,
|
26
|
+
:short => "-a ATTRIBUTES",
|
27
|
+
:long => "--attributes",
|
28
|
+
:description => "To project only required attributes"
|
29
|
+
|
30
|
+
option :suppress_attribute_names,
|
31
|
+
:long => "--suppress-attribute-names",
|
32
|
+
:description => "Print only entity description attribute values and no keys",
|
33
|
+
:boolean => true,
|
34
|
+
:default => false
|
35
|
+
|
36
|
+
|
37
|
+
private
|
38
|
+
def default_attributes
|
39
|
+
["vpc_id", "cidr_block", "instance_tenancy", "is_default", "tags"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def findby tags
|
43
|
+
ec2connect
|
44
|
+
@ec2client.describe_vpcs({dry_run: false, filters: tags}).vpcs
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: knife-ec2find
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mikhail Advani
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: chef
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '12.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '12.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-core
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-expectations
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-mocks
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec_junit_formatter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Referencing of resources needs to be done by ids but the only controlled
|
98
|
+
attributes are tags. This is a knife plugin to help you get the id using tags
|
99
|
+
email:
|
100
|
+
- mikhail.advani@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files:
|
104
|
+
- LICENSE
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- knife-ec2find.gemspec
|
110
|
+
- lib/chef/knife/ec2_find_acl.rb
|
111
|
+
- lib/chef/knife/ec2_find_base.rb
|
112
|
+
- lib/chef/knife/ec2_find_cgw.rb
|
113
|
+
- lib/chef/knife/ec2_find_igw.rb
|
114
|
+
- lib/chef/knife/ec2_find_image.rb
|
115
|
+
- lib/chef/knife/ec2_find_instance.rb
|
116
|
+
- lib/chef/knife/ec2_find_rtb.rb
|
117
|
+
- lib/chef/knife/ec2_find_sg.rb
|
118
|
+
- lib/chef/knife/ec2_find_subnet.rb
|
119
|
+
- lib/chef/knife/ec2_find_vpc.rb
|
120
|
+
- lib/knife-ec2find/version.rb
|
121
|
+
homepage: https://github.com/mikhailadvani/knife-ec2find
|
122
|
+
licenses:
|
123
|
+
- Apache
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.4.5
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: AWS resource finder by tags using knife
|
145
|
+
test_files: []
|