hocho-ec2 0.1.0 → 0.2.0
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.
- checksums.yaml +5 -5
- data/lib/hocho-ec2/version.rb +1 -1
- data/lib/hocho/inventory_providers/ec2.rb +14 -5
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 51c129620328777a9815f34fb6231b5240295d256a38e26a3f51a75821e4744f
|
4
|
+
data.tar.gz: 9518a6da4b6437293c7531d397d665162055d4e316311cc75962b08380350a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8febe9892932bfec8fc1fcbe7275e0cf32b862aa68dda935d4434ab383910156c0c4b094ad589fb191af5e02d005ef678b5a6bf110ebd78c589a9ea33536733
|
7
|
+
data.tar.gz: c6904281b1b6b611a1fbdf1aaa882f2d3989d50a299d2e096bb6ec64786239683369954557448c250e2fa7e4d922494f67e81159c5043dac177f7a6bdb67c2ff
|
data/lib/hocho-ec2/version.rb
CHANGED
@@ -60,12 +60,19 @@ module Hocho
|
|
60
60
|
[vpc.vpc_id, vpc]
|
61
61
|
end
|
62
62
|
end.to_h
|
63
|
+
subnets= ec2.describe_subnets().flat_map do |page|
|
64
|
+
page.subnets.map do |subnet|
|
65
|
+
[subnet.subnet_id, subnet]
|
66
|
+
end
|
67
|
+
end.to_h
|
63
68
|
ec2.describe_instances(filters: filters).flat_map do |page|
|
64
69
|
page.reservations.flat_map do |reservation|
|
65
70
|
reservation.instances.map do |instance|
|
71
|
+
next if instance.state.name == 'terminated' || instance.state.name == 'terminating'
|
66
72
|
vpc = vpcs[instance.vpc_id]
|
67
|
-
|
68
|
-
|
73
|
+
subnet = subnets[instance.subnet_id]
|
74
|
+
fetch_instance(instance, vpc, subnet)
|
75
|
+
end.compact
|
69
76
|
end
|
70
77
|
end
|
71
78
|
end
|
@@ -104,11 +111,12 @@ module Hocho
|
|
104
111
|
|
105
112
|
private
|
106
113
|
|
107
|
-
def fetch_instance(instance, vpc)
|
114
|
+
def fetch_instance(instance, vpc, subnet)
|
108
115
|
tags = {
|
109
116
|
'ec2.instance-id' => instance.instance_id,
|
110
117
|
'ec2.iam-instance-profile' => instance.iam_instance_profile,
|
111
118
|
'ec2.vpc-id' => instance.vpc_id,
|
119
|
+
'ec2.subnet-id' => instance.subnet_id,
|
112
120
|
}
|
113
121
|
{'vpc-tags' => vpc.tags, 'tags' => instance.tags}.each do |prefix, aws_tags|
|
114
122
|
aws_tags.each do |tag|
|
@@ -118,13 +126,14 @@ module Hocho
|
|
118
126
|
|
119
127
|
ec2_attribute = instance.to_h
|
120
128
|
vpc_attribute = vpc.to_h
|
121
|
-
|
129
|
+
subnet_attribute = subnet.to_h
|
130
|
+
[ec2_attribute, vpc_attribute, subnet_attribute].each do |attrs|
|
122
131
|
attrs[:tags] = attrs.fetch(:tags, []).map { |_| [_.fetch(:key), _.fetch(:value)] }.to_h
|
123
132
|
end
|
124
133
|
|
125
134
|
properties = {
|
126
135
|
run_list: runlist_template.new(instance, vpc).result(),
|
127
|
-
attributes: {hocho_ec2: ec2_attribute, hocho_vpc: vpc_attribute,},
|
136
|
+
attributes: {hocho_ec2: ec2_attribute, hocho_vpc: vpc_attribute, hocho_subnet: subnet_attribute,},
|
128
137
|
}
|
129
138
|
{
|
130
139
|
name: hostname_template.new(instance, vpc).result(),
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hocho-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sorah Fukumori
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-ec2
|
@@ -105,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
|
109
|
-
rubygems_version: 2.6.13
|
108
|
+
rubygems_version: 3.0.3
|
110
109
|
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: Hocho gem plugin to discover hosts in EC2
|