terrafying 1.2.2 → 1.2.3

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: af4653ed17899f16c1509603765cbb7a46df21a8
4
- data.tar.gz: 4c80f22154d070d64f964bb24d2fe9b55be56fee
3
+ metadata.gz: a22e15cb8bade7db18b7a76f6a6c912b52476cfd
4
+ data.tar.gz: 71551b258663fd61a90374074cbab2c1016f2177
5
5
  SHA512:
6
- metadata.gz: 28051808a96919423aa46e77a49b14ad41599a7b9525c31b23b78d0fbb8fe16715647757d76d9ee584c6c7a43b75cf852cb164b9ee7e35bcb59714f9d4653686
7
- data.tar.gz: c57af13c2ea754312cb07f5028ca5eacdca8b515b5ef23af371e6e36bf91eff329f9a44b2bba9b12ca0af69e53aed912acc499521bbc9e599afc85ac566077e6
6
+ metadata.gz: d2e658117299c524fb658e489b95ba6289414a9c246600abdde4d30d18bbdb8dc177e3b5a3695ae1a9605772631c5ab4c9bf2cafde56da7a2fe9a00dac4405ac
7
+ data.tar.gz: f45615ee481693852540c32e90971d34d3f8a9348b1f3462399945fd89e10920290b392dfee261cf1ba23eeea078f3e7f29efa5eab2424eecfdc9e0c8d87dc97
@@ -9,8 +9,12 @@ module Terrafying
9
9
  attr_reader :region
10
10
 
11
11
  def initialize(region)
12
+ full_jitter = lambda { |c| Kernel.sleep(Kernel.rand(0..[2, (0.3 * 2**c.retries)].min)) }
13
+
12
14
  ::Aws.config.update({
13
- region: region
15
+ region: region,
16
+ retry_limit: 5,
17
+ retry_backoff: full_jitter
14
18
  })
15
19
  @autoscaling_client = ::Aws::AutoScaling::Client.new
16
20
  @ec2_resource = ::Aws::EC2::Resource.new
@@ -353,15 +357,22 @@ module Terrafying
353
357
  @hosted_zones[tag] ||=
354
358
  begin
355
359
  STDERR.puts "looking for a hosted zone with tag '#{tag}'"
356
- hosted_zones = @route53_client.list_hosted_zones().hosted_zones.select { |zone|
357
- tags = @route53_client.list_tags_for_resource({resource_type: "hostedzone", resource_id: zone.id.split('/')[2]}).resource_tag_set.tags.select { |aws_tag|
358
- tag.keys.any? { |key| String(key) == aws_tag.key && tag[key] == aws_tag.value }
360
+ @aws_hosted_zones ||= @route53_client.list_hosted_zones.hosted_zones.map do |zone|
361
+ {
362
+ zone: zone,
363
+ tags: @route53_client.list_tags_for_resource({resource_type: "hostedzone", resource_id: zone.id.split('/')[2]}).resource_tag_set.tags
359
364
  }
360
- tags.any?
361
- }
365
+ end
366
+
367
+ hosted_zones = @aws_hosted_zones.select do |z|
368
+ z[:tags].any? do |aws_tag|
369
+ tag.any? { |k, v| aws_tag.key = String(k) && aws_tag.value == v }
370
+ end
371
+ end
372
+
362
373
  case
363
374
  when hosted_zones.count == 1
364
- hosted_zones.first
375
+ hosted_zones.first[:zone]
365
376
  when hosted_zones.count < 1
366
377
  raise "No hosted zone with tag '#{tag}' was found."
367
378
  when hosted_zones.count > 1
@@ -1,4 +1,4 @@
1
1
  module Terrafying
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  CLI_VERSION = "0.11.2"
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.2.2
4
+ version: 1.2.3
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-02-06 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler