terrafying 1.3.3 → 1.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 908b4d5b97e8cc2fba65f7a48e42db4f99a9f3da
4
- data.tar.gz: 466a5c6ebf10ea443728fc6b34ac64c94b31b71b
3
+ metadata.gz: 79b501b5f9ac84fab8591bdacd4cc5c30e4810b5
4
+ data.tar.gz: dbbac5466269c2e01a853c3d92c7e09d05378d43
5
5
  SHA512:
6
- metadata.gz: 03361ad93172d6e21ccfdc208654c780d16ca0b052895237c3316acd255c16ecacae844890b15deb7bdc9cc2a39fe04fa910600587c7fed2ea1cb67f0ee27e36
7
- data.tar.gz: 2374c5f836fc6ae5e96d89a287c3aba69499694593f2a5603b844e187335f8a83415ca1ce4e66e11fe1437a0b0b621bee6eabd34e148b64528152ebd54a54489
6
+ metadata.gz: 4b00037a9778771192addfab9afd6655ad777c3f12006290ea292a393ba3f7f37db58b023da6550345973b2a18ba57a673e1b6f1ffc8e0cce44863e17af0c0ac
7
+ data.tar.gz: 68e0a28098c4e66369a8ef491ecd44cbe82413b3ff98364335d939240a77a01e6e285d4248d50e955c4b7a23925783616a605509cc48162da2f949c2f3f01008
@@ -56,6 +56,35 @@ module Terrafying
56
56
  end
57
57
  end
58
58
 
59
+ def security_group_in_vpc(vpc_id, name)
60
+ @security_groups_in_vpc ||= {}
61
+ @security_groups_in_vpc[vpc_id + name] ||=
62
+ begin
63
+ STDERR.puts "Looking up id of security group '#{name}'"
64
+ groups = @ec2_resource.security_groups(
65
+ {
66
+ filters: [
67
+ {
68
+ name: "group-name",
69
+ values: [name],
70
+ },
71
+ {
72
+ name: "vpc-id",
73
+ values: [vpc_id],
74
+ }
75
+ ],
76
+ }).limit(2)
77
+ case
78
+ when groups.count == 1
79
+ groups.first.id
80
+ when groups.count < 1
81
+ raise "No security group with name '#{name}' was found."
82
+ when groups.count > 1
83
+ raise "More than one security group with name '#{name}' found: " + groups.join(', ')
84
+ end
85
+ end
86
+ end
87
+
59
88
  def security_group_by_tags(tags)
60
89
  @security_groups_by_tags ||= {}
61
90
  @security_groups_by_tags[tags] ||=
@@ -161,6 +190,10 @@ module Terrafying
161
190
  names.map{|n| security_group(n)}
162
191
  end
163
192
 
193
+ def security_groups_in_vpc(vpc_id, *names)
194
+ names.map{|n| security_group_in_vpc(vpc_id, n)}
195
+ end
196
+
164
197
  def subnet(name)
165
198
  @subnets ||= {}
166
199
  @subnets[name] ||=
@@ -25,6 +25,10 @@ module Terrafying
25
25
  "${#{@var}}"
26
26
  end
27
27
 
28
+ def to_str
29
+ self.to_s
30
+ end
31
+
28
32
  def <=>(other)
29
33
  self.to_s <=> other.to_s
30
34
  end
@@ -1,4 +1,4 @@
1
1
  module Terrafying
2
- VERSION = "1.3.3" # will be inserted by Drone
2
+ VERSION = "1.3.4" # will be inserted by Drone
3
3
  CLI_VERSION = "0.11.3"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terrafying
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - uSwitch Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler