ruby_aem_aws 1.5.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/conf/gem.yaml +1 -1
  3. data/lib/ruby_aem_aws/abstract/cloudwatch.rb +1 -1
  4. data/lib/ruby_aem_aws/abstract/component.rb +1 -1
  5. data/lib/ruby_aem_aws/abstract/grouped_component.rb +1 -1
  6. data/lib/ruby_aem_aws/abstract/single_component.rb +1 -1
  7. data/lib/ruby_aem_aws/abstract/snapshot.rb +1 -1
  8. data/lib/ruby_aem_aws/abstract/stackmanager.rb +1 -1
  9. data/lib/ruby_aem_aws/architecture/consolidated_stack.rb +1 -1
  10. data/lib/ruby_aem_aws/architecture/full_set_stack.rb +2 -2
  11. data/lib/ruby_aem_aws/architecture/stack_manager.rb +1 -1
  12. data/lib/ruby_aem_aws/client/cloudwatch.rb +1 -1
  13. data/lib/ruby_aem_aws/client/dynamo_db.rb +1 -1
  14. data/lib/ruby_aem_aws/client/s3.rb +1 -1
  15. data/lib/ruby_aem_aws/client/sns_topic.rb +1 -1
  16. data/lib/ruby_aem_aws/component/author.rb +2 -2
  17. data/lib/ruby_aem_aws/component/author_dispatcher.rb +2 -2
  18. data/lib/ruby_aem_aws/component/author_primary.rb +1 -1
  19. data/lib/ruby_aem_aws/component/author_publish_dispatcher.rb +1 -1
  20. data/lib/ruby_aem_aws/component/author_standby.rb +1 -1
  21. data/lib/ruby_aem_aws/component/chaos_monkey.rb +1 -1
  22. data/lib/ruby_aem_aws/component/component_descriptor.rb +1 -1
  23. data/lib/ruby_aem_aws/component/orchestrator.rb +1 -1
  24. data/lib/ruby_aem_aws/component/publish.rb +1 -1
  25. data/lib/ruby_aem_aws/component/publish_dispatcher.rb +2 -2
  26. data/lib/ruby_aem_aws/component/stack_manager_resources.rb +1 -1
  27. data/lib/ruby_aem_aws/constants.rb +12 -7
  28. data/lib/ruby_aem_aws/error.rb +2 -2
  29. data/lib/ruby_aem_aws/mixins/healthy_count_verifier.rb +50 -20
  30. data/lib/ruby_aem_aws/mixins/healthy_resource_verifier.rb +46 -19
  31. data/lib/ruby_aem_aws/mixins/healthy_state_verifier.rb +1 -1
  32. data/lib/ruby_aem_aws/mixins/instance_describer.rb +1 -1
  33. data/lib/ruby_aem_aws/mixins/metric_verifier.rb +1 -1
  34. data/lib/ruby_aem_aws/mixins/snapshot_verifier.rb +1 -1
  35. data/lib/ruby_aem_aws.rb +5 -3
  36. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae2d23eb45fce95d159684a8b556feb24c638046
4
- data.tar.gz: c127bec2c5002dcb157577c9f70ae16a6ace5d1c
3
+ metadata.gz: 6e03800c323cf88f17f022f87f3df8bcd3316d95
4
+ data.tar.gz: 6288fdc5638777b3160dde0ef53b6e6579292741
5
5
  SHA512:
6
- metadata.gz: 0cfee40d46a45d145c413ceab6811188210a6a1495bb277aa596d0497fd099f5440c4aebddbd461dc5fd2bab100d9ecd778726192beca13fd47f89332e4b7232
7
- data.tar.gz: eaaadb2ebfd4f17e720cc4ad9578fc30b8247d8d2f95e44cb44d40f8524a8c5c3b744e2cc90a9a6d7b434ba46a8e029c197527ae3c1f2a0beda4b39f37a37431
6
+ metadata.gz: f62da424b5d615bfb8cb7a057c622335c781e47949cf3a7b590da51f1e8005cc93010bf789ff524019fa1fe5f3fcada98288f58a61880293a1c655094f0c34d6
7
+ data.tar.gz: 524f111c5a735488159a963c6354b714a784f9720e0d9556febf923b94a59ffd1d31b2b210ee2870341d924071eeee5608b0946abe6eec38bbe49b62956471fd
data/conf/gem.yaml CHANGED
@@ -1 +1 @@
1
- version: 1.5.0
1
+ version: 2.2.0
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ module RubyAemAws
33
33
  # - CloudWatchClient: AWS Cloudwatch Client.
34
34
  # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
35
35
  # - Ec2Resource: AWS EC2 Resource connection.
36
- # - ElbClient: AWS ElasticLoadBalancer Client.
36
+ # - ElbClient: AWS ElasticLoadBalancer v2 Client.
37
37
  # @return new RubyAemAws::FullSetStack instance
38
38
  def initialize(stack_prefix, params)
39
39
  @author_aws_clients = {
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ module RubyAemAws
29
29
  # - CloudWatchClient: AWS Cloudwatch Client.
30
30
  # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
31
31
  # - Ec2Resource: AWS EC2 Resource connection.
32
- # - ElbClient: AWS ElasticLoadBalancer Client.
32
+ # - ElbClient: AWS ElasticLoadBalancer v2 Client.
33
33
  # @return new RubyAemAws::FullSet::Author
34
34
  def initialize(stack_prefix, params)
35
35
  author_aws_clients = {
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ module RubyAemAws
42
42
  # - CloudWatchClient: AWS Cloudwatch Client.
43
43
  # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
44
44
  # - Ec2Resource: AWS EC2 Resource connection.
45
- # - ElbClient: AWS ElasticLoadBalancer Client.
45
+ # - ElbClient: AWS ElasticLoadBalancer v2 Client.
46
46
  # @return new RubyAemAws::FullSet::AuthorDispatcher
47
47
  def initialize(stack_prefix, params)
48
48
  @descriptor = ComponentDescriptor.new(stack_prefix,
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ module RubyAemAws
41
41
  # - CloudWatchClient: AWS Cloudwatch Client.
42
42
  # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
43
43
  # - Ec2Resource: AWS EC2 Resource connection.
44
- # - ElbClient: AWS ElasticLoadBalancer Client.
44
+ # - ElbClient: AWS ElasticLoadBalancer v2 Client.
45
45
  # @return new RubyAemAws::FullSet::PublishDispatcher
46
46
  def initialize(stack_prefix, params)
47
47
  @descriptor = ComponentDescriptor.new(stack_prefix,
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -35,19 +35,24 @@ module RubyAemAws
35
35
  end
36
36
 
37
37
  class ELBInstanceState
38
- INSERVICE = 'InService'.freeze
39
- OUTOFSERVICE = 'OutOfService'.freeze
38
+ DRAINING = 'draining'.freeze
39
+ HEALTHY = 'healthy'.freeze
40
+ INITIAL = 'initial'.freeze
41
+ UNAVAILABLE = 'unavailable'.freeze
42
+ UNHEALTHY = 'unhealthy'.freeze
43
+ UNUSED = 'unused'.freeze
40
44
 
41
- ALL_ACTIVE = [INSERVICE, OUTOFSERVICE].freeze
45
+ ALL_ACTIVE = [HEALTHY, INITIAL, UNAVAILABLE, UNUSED].freeze
42
46
  end
43
47
 
44
48
  class Constants
45
49
  REGION_DEFAULT = ENV['AWS_DEFAULT_REGION'] || ENV['aws_default_region'] || ENV['AWS_REGION'] || ENV['aws_region'] || 'ap-southeast-2'.freeze
46
50
  ACCESS_KEY_ID = ENV['AWS_ACCESS_KEY_ID'] || ENV['aws_access_key_id']
47
- SECRET_ACCESS_KEY = ENV['AWS_SECRET_ACCESS_KEY'] || ENV['aws_scret_access_key']
48
- PROFILE = ENV['AWS_PROFILE']
51
+ SECRET_ACCESS_KEY = ENV['AWS_SECRET_ACCESS_KEY'] || ENV['aws_secret_access_key']
52
+ SESSION_TOKEN = ENV['AWS_SESSION_TOKEN'] || ENV['aws_session_token']
53
+ PROFILE = ENV['AWS_PROFILE'] || ENV['aws_profile']
49
54
  INSTANCE_STATE_HEALTHY = RubyAemAws::InstanceState::RUNNING.freeze
50
55
  INSTANCE_STATE_CODE_RUNNING = RubyAemAws::InstanceStateCode::RUNNING
51
- ELB_INSTANCE_INSERVICE = RubyAemAws::ELBInstanceState::INSERVICE.freeze
56
+ ELB_INSTANCE_INSERVICE = RubyAemAws::ELBInstanceState::HEALTHY.freeze
52
57
  end
53
58
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ module RubyAemAws
53
53
  def initialize(msg = "No credentials found!
54
54
  Set environment variable AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or AWS_PROFILE.
55
55
  Alternative use following syntax:
56
- RubyAemAws::AemAws.new(aws_access_key_id, aws_scret_access_key) or
56
+ RubyAemAws::AemAws.new(aws_access_key_id, aws_secret_access_key) or
57
57
  RubyAemAws::AemAws.new(credentials_profile_name)")
58
58
  super
59
59
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -48,7 +48,10 @@ module RubyAemAws
48
48
  return :no_elb if elb.nil?
49
49
 
50
50
  elb_running_instances = 0
51
- get_instances_state_from_elb(elb).each do |i|
51
+ elb_instances = get_instances_state(elb_client, elb)
52
+ return :no_elb_targets if elb_instances.nil?
53
+
54
+ elb_instances.each do |i|
52
55
  elb_running_instances += 1 if i[:state] == RubyAemAws::Constants::INSTANCE_STATE_HEALTHY
53
56
  end
54
57
 
@@ -108,44 +111,71 @@ module RubyAemAws
108
111
  nil
109
112
  end
110
113
 
111
- # @return ElasticLoadBalancer by StackPrefix and logical-id tags.
114
+ # @return ElasticLoadBalancer Arn.
112
115
  def find_elb(elb_client)
113
- elbs = elb_client.describe_load_balancers.load_balancer_descriptions
116
+ elbs = elb_client.describe_load_balancers(page_size: 50)
117
+ elb_arn = find_elb_arn(elbs.load_balancers)
118
+
119
+ return elb_arn unless elb_arn.nil?
120
+
121
+ until elbs.last_page?
122
+ elbs = elb_client.describe_load_balancers(page_size: 50, marker: elbs.next_marker)
123
+ elb_arn = find_elb_arn(elbs.load_balancers)
124
+ return elb_arn unless elb_arn.nil?
125
+ end
126
+ nil
127
+ end
128
+
129
+ # @return ElasticLoadBalancer Arn by StackPrefix tag & ELB name.
130
+ def find_elb_arn(elbs)
114
131
  elbs.each do |elb|
115
132
  elb_matches_stack_prefix = false
116
- elb_matches_logical_id = false
117
- tag_descriptions = elb_client.describe_tags(load_balancer_names: [elb.load_balancer_name]).tag_descriptions
133
+ elb_matches_name = false
134
+ begin
135
+ tag_descriptions = elb_client.describe_tags(resource_arns: [elb.load_balancer_arn]).tag_descriptions
136
+ rescue Aws::ElasticLoadBalancingV2::Errors::LoadBalancerNotFound
137
+ next
138
+ end
139
+
118
140
  next if tag_descriptions.empty?
119
141
 
120
142
  tags = tag_descriptions[0].tags
121
143
  tags.each do |tag|
122
- if tag.key == 'StackPrefix' && tag.value == descriptor.stack_prefix
123
- elb_matches_stack_prefix = true
124
- break if elb_matches_logical_id
144
+ elb_matches_stack_prefix = true if tag.key == 'StackPrefix' && tag.value == descriptor.stack_prefix
145
+ elb_matches_name = true if tag.key == 'Name' && tag.value == descriptor.elb.name
125
146
 
126
- next
127
- end
128
- if tag.key == 'aws:cloudformation:logical-id' && tag.value == descriptor.elb.id
129
- elb_matches_logical_id = true
130
- break if elb_matches_stack_prefix
131
- end
147
+ return elb.load_balancer_arn if elb_matches_stack_prefix && elb_matches_name
148
+
149
+ next
132
150
  end
133
- return elb if elb_matches_stack_prefix && elb_matches_logical_id
134
151
  end
135
152
  nil
136
153
  end
137
154
 
138
- def get_instances_state_from_elb(elb)
155
+ def get_instances_state(elb_client, elb_arn)
156
+ described_target_groups = elb_client.describe_target_groups(load_balancer_arn: elb_arn)
157
+
158
+ return nil if described_target_groups.target_groups.empty?
159
+
160
+ target_group = described_target_groups.target_groups[0]
161
+ target_group_arn = target_group.target_group_arn
162
+
163
+ described_target_health = elb_client.describe_target_health(target_group_arn: target_group_arn)
164
+
165
+ return nil if described_target_health.target_health_descriptions.empty?
166
+
167
+ targets = described_target_health.target_health_descriptions
168
+
139
169
  stack_prefix_instances = []
140
- elb.instances.each do |i|
141
- instance = get_instance_by_id(i.instance_id)
170
+ targets.each do |t|
171
+ instance = get_instance_by_id(t.target.id)
142
172
  next if instance.nil?
143
173
 
144
174
  instance.tags.each do |tag|
145
175
  next if tag.key != 'StackPrefix'
146
176
  break if tag.value != descriptor.stack_prefix
147
177
 
148
- stack_prefix_instances.push(id: i.instance_id, state: instance.state.name)
178
+ stack_prefix_instances.push(id: t.target.id, state: instance.state.name)
149
179
  end
150
180
  end
151
181
  stack_prefix_instances
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -53,15 +53,15 @@ module RubyAemAws
53
53
  elb = find_elb(elb_client)
54
54
  return :no_elb if elb.nil?
55
55
 
56
- elb_instance_state = elb_client.describe_instance_health(load_balancer_name: elb.load_balancer_name)
56
+ elb_instance_state = get_instances_elb_state(elb_client, elb)
57
+ return :no_elb_targets if elb_instance_state.nil?
57
58
 
58
59
  elb_running_instances = 0
59
- elb_instance_state.instance_states.each do |i|
60
- elb_running_instances += 1 if i.state == RubyAemAws::Constants::ELB_INSTANCE_INSERVICE
60
+ elb_instance_state.each do |i|
61
+ elb_running_instances += 1 if i.target_health.state == RubyAemAws::Constants::ELB_INSTANCE_INSERVICE
61
62
  end
62
63
 
63
64
  desired_capacity = asg.desired_capacity
64
-
65
65
  return :misconfigured if desired_capacity < 1
66
66
  return :recovering if elb_running_instances < desired_capacity
67
67
  return :scaling if elb_running_instances > desired_capacity
@@ -158,31 +158,58 @@ module RubyAemAws
158
158
  nil
159
159
  end
160
160
 
161
- # @return ElasticLoadBalancer by StackPrefix and logical-id tags.
161
+ # @return ElasticLoadBalancer Arn.
162
162
  def find_elb(elb_client)
163
- elbs = elb_client.describe_load_balancers.load_balancer_descriptions
163
+ elbs = elb_client.describe_load_balancers(page_size: 50)
164
+ elb_arn = find_elb_arn(elbs.load_balancers)
165
+
166
+ return elb_arn unless elb_arn.nil?
167
+
168
+ until elbs.last_page?
169
+ elbs = elb_client.describe_load_balancers(page_size: 50, marker: elbs.next_marker)
170
+ elb_arn = find_elb_arn(elbs.load_balancers)
171
+ return elb_arn unless elb_arn.nil?
172
+ end
173
+ nil
174
+ end
175
+
176
+ # @return ElasticLoadBalancer Arn by StackPrefix tag & ELB name.
177
+ def find_elb_arn(elbs)
164
178
  elbs.each do |elb|
165
179
  elb_matches_stack_prefix = false
166
- elb_matches_logical_id = false
167
- tag_descriptions = elb_client.describe_tags(load_balancer_names: [elb.load_balancer_name]).tag_descriptions
180
+ elb_matches_name = false
181
+ begin
182
+ tag_descriptions = elb_client.describe_tags(resource_arns: [elb.load_balancer_arn]).tag_descriptions
183
+ rescue Aws::ElasticLoadBalancingV2::Errors::LoadBalancerNotFound
184
+ next
185
+ end
186
+
168
187
  next if tag_descriptions.empty?
169
188
 
170
189
  tags = tag_descriptions[0].tags
171
190
  tags.each do |tag|
172
- if tag.key == 'StackPrefix' && tag.value == descriptor.stack_prefix
173
- elb_matches_stack_prefix = true
174
- break if elb_matches_logical_id
191
+ elb_matches_stack_prefix = true if tag.key == 'StackPrefix' && tag.value == descriptor.stack_prefix
192
+ elb_matches_name = true if tag.key == 'Name' && tag.value == descriptor.elb.name
175
193
 
176
- next
177
- end
178
- if tag.key == 'aws:cloudformation:logical-id' && tag.value == descriptor.elb.id
179
- elb_matches_logical_id = true
180
- break if elb_matches_stack_prefix
181
- end
194
+ return elb.load_balancer_arn if elb_matches_stack_prefix && elb_matches_name
182
195
  end
183
- return elb if elb_matches_stack_prefix && elb_matches_logical_id
184
196
  end
185
197
  nil
186
198
  end
199
+
200
+ def get_instances_elb_state(elb_client, elb_arn)
201
+ described_target_groups = elb_client.describe_target_groups(load_balancer_arn: elb_arn)
202
+
203
+ return nil if described_target_groups.target_groups.empty?
204
+
205
+ target_group = described_target_groups.target_groups[0]
206
+ target_group_arn = target_group.target_group_arn
207
+
208
+ described_target_health = elb_client.describe_target_health(target_group_arn: target_group_arn)
209
+
210
+ return nil if described_target_health.target_health_descriptions.empty?
211
+
212
+ described_target_health.target_health_descriptions
213
+ end
187
214
  end
188
215
  end
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
data/lib/ruby_aem_aws.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2018 Shine Solutions
1
+ # Copyright 2018-2021 Shine Solutions Group
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -23,17 +23,19 @@ module RubyAemAws
23
23
  # - aws_region: the AWS region (eg ap-southeast-2)
24
24
  # - aws_access_key_id: the AWS access key
25
25
  # - aws_secret_access_key: the AWS secret access key
26
+ # - aws_session_token: session token from STS
26
27
  # - aws_profile: AWS profile name
27
28
  # @return new RubyAemAws::AemAws instance
28
29
  def initialize(conf = {})
29
30
  conf[:aws_region] ||= Constants::REGION_DEFAULT
30
31
  conf[:aws_access_key_id] ||= Constants::ACCESS_KEY_ID
31
32
  conf[:aws_secret_access_key] ||= Constants::SECRET_ACCESS_KEY
33
+ conf[:aws_session_token] ||= Constants::SESSION_TOKEN
32
34
  conf[:aws_profile] ||= Constants::PROFILE
33
35
 
34
36
  Aws.config.update(region: conf[:aws_region])
35
37
 
36
- credentials = Aws::Credentials.new(conf[:aws_access_key_id], conf[:aws_secret_access_key]) unless conf[:aws_access_key_id].nil?
38
+ credentials = Aws::Credentials.new(conf[:aws_access_key_id], conf[:aws_secret_access_key], conf[:aws_session_token]) unless conf[:aws_access_key_id].nil?
37
39
  credentials = Aws::SharedCredentials.new(profile_name: conf[:aws_profile]) unless conf[:aws_profile].nil?
38
40
  credentials = Aws::InstanceProfileCredentials.new if conf[:aws_profile].nil? && conf[:aws_access_key_id].nil?
39
41
  raise RubyAemAws::ArgumentError unless defined? credentials
@@ -111,7 +113,7 @@ module RubyAemAws
111
113
  {
112
114
  Ec2Client: Aws::EC2::Client.new,
113
115
  Ec2Resource: Aws::EC2::Resource.new,
114
- ElbClient: Aws::ElasticLoadBalancing::Client.new(
116
+ ElbClient: Aws::ElasticLoadBalancingV2::Client.new(
115
117
  retry_limit: 20
116
118
  ),
117
119
  AutoScalingClient: Aws::AutoScaling::Client.new(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_aem_aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shine Solutions
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-01 00:00:00.000000000 Z
11
+ date: 2021-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk