terrafying 1.4.1 → 1.4.2

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
  SHA256:
3
- metadata.gz: d7af82bed5ac5b15aff46f06985044ca2e9593090c8d12cb14d1be2df9047e79
4
- data.tar.gz: ecf070235ef345d2ad44b3f12bdc8b14877dc454820aba8fb1012ed62f371cff
3
+ metadata.gz: bb9ef6d8e5f98f1eb34773c6138746890260b3ac68986933e9141c4967704207
4
+ data.tar.gz: d35559c342dd1e58909638ba2d21354830090b694859331a62ebd8f95b0a21a1
5
5
  SHA512:
6
- metadata.gz: e59e77c9d8a9c8793a9bcf2c76f967ee1382923f85c27363e9e71c0bec8bfc7cf1f011cbd06e37f27678221eefe5b49600d480f8546e845e948b40c321c0a5f6
7
- data.tar.gz: 3b48905bb77b0f8a21faabe4b9aa9888c652d6afa03c59ad595da26727b6af0c81fc27a966b873f82d8542a9eac8f4d88acdad2b4e1c1120a335d734d429c75d
6
+ metadata.gz: 70cfa741429359b2de0a8736717dcafa867982247d6828a375e29ad8e20c6b9e983c8c2faef12fe47f5aecc4e45b5bbf19f4ed03cc3f11156f0eb27ee483f7c7
7
+ data.tar.gz: daba0a99b92b5c6fe83b1c5358161d9b74ccd2c2dafaebbf4c974fb0163d1bf3f0dfada583c61b649f539d70bd6436dcdbda799338c8589a4841d9a49ead9990
@@ -40,20 +40,16 @@ module Terrafying
40
40
  @account_id_cache ||= @sts_client.get_caller_identity.account
41
41
  end
42
42
 
43
+ def all_security_groups
44
+ @all_security_groups ||= @ec2_resource.security_groups.to_a
45
+ end
46
+
43
47
  def security_group(name)
44
48
  @security_groups ||= {}
45
49
  @security_groups[name] ||=
46
50
  begin
47
51
  STDERR.puts "Looking up id of security group '#{name}'"
48
- groups = @ec2_resource.security_groups(
49
- {
50
- filters: [
51
- {
52
- name: "group-name",
53
- values: [name],
54
- },
55
- ],
56
- }).limit(2)
52
+ groups = all_security_groups.select { |g| g.group_name == name }.take(2)
57
53
  case
58
54
  when groups.count == 1
59
55
  groups.first.id
@@ -70,19 +66,7 @@ module Terrafying
70
66
  @security_groups_in_vpc[vpc_id + name] ||=
71
67
  begin
72
68
  STDERR.puts "Looking up id of security group '#{name}'"
73
- groups = @ec2_resource.security_groups(
74
- {
75
- filters: [
76
- {
77
- name: "group-name",
78
- values: [name],
79
- },
80
- {
81
- name: "vpc-id",
82
- values: [vpc_id],
83
- }
84
- ],
85
- }).limit(2)
69
+ groups = all_security_groups.select { |g| g.vpc_id == vpc_id && g.group_name == name }.take(2)
86
70
  case
87
71
  when groups.count == 1
88
72
  groups.first.id
@@ -98,20 +82,7 @@ module Terrafying
98
82
  @security_groups_by_tags ||= {}
99
83
  @security_groups_by_tags[tags] ||=
100
84
  begin
101
- groups = @ec2_client.describe_security_groups(
102
- {
103
- filters: [
104
- {
105
- name: "tag-key",
106
- values: tags.keys,
107
- },
108
- {
109
- name: "tag-value",
110
- values: tags.values
111
- }
112
- ]
113
- },
114
- ).security_groups
85
+ groups = all_security_groups.select { |g| g.tags.any? { |t| t.key == tags.keys && t.value == tags.values } }.take(2)
115
86
  case
116
87
  when groups.count == 1
117
88
  groups.first.id
@@ -1,4 +1,4 @@
1
1
  module Terrafying
2
- VERSION = "1.4.1" # will be inserted by Drone
2
+ VERSION = "1.4.2" # will be inserted by Drone
3
3
  CLI_VERSION = "0.11.7"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terrafying
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - uSwitch Limited