ruby_aem_aws 1.4.0 → 2.1.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.
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 +3 -3
  4. data/lib/ruby_aem_aws/abstract/component.rb +1 -2
  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 +2 -2
  9. data/lib/ruby_aem_aws/architecture/consolidated_stack.rb +1 -6
  10. data/lib/ruby_aem_aws/architecture/full_set_stack.rb +2 -40
  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 -2
  27. data/lib/ruby_aem_aws/constants.rb +12 -7
  28. data/lib/ruby_aem_aws/error.rb +2 -9
  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 +2 -2
  34. data/lib/ruby_aem_aws/mixins/snapshot_verifier.rb +1 -1
  35. data/lib/ruby_aem_aws.rb +7 -25
  36. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 143bcd08d3dcf1d4bf7955a43031c7734b5048c9
4
- data.tar.gz: 7b61a8d54896d4021158fd9ce0dce4c50bb05264
3
+ metadata.gz: edf9ceb92a749def70b1e6e77657080a4757495f
4
+ data.tar.gz: a8d1f5d6c776d8a9be4d0d9b59e16e8279ceb289
5
5
  SHA512:
6
- metadata.gz: 2a3c723d12b9cbb095f175b8503300e997ff980374355170fb51acb6d10101c298f271577f6ed4847954c4fe2b326ac3f61f9582e73d33c42ed1a288dcfabe70
7
- data.tar.gz: 4d25ad2d48f49ad2cc1d87f2492f2d112d7c5625f385210eb770524f1a9130df0e20eb3331c914469a69fd5220e49374c6cf5af8d00a85c2afdfbda17fbe8f94
6
+ metadata.gz: dcc5fe4b4d0a0e197b6f743a3c63532b4e069b5c50b038b2545acd649bc1d7cf7f49b780c3d16c3a7d0bb28318a55b248d29ce9aaf77c164b4b8315ad4aafb10
7
+ data.tar.gz: 7ef88b57050e47973b5c122ea46ec87400e665f92f305183dc34f1ba1ac743cf1d0e323f5312b7eda6414a5c135954ad5b31460fe051f7927616bcfee769aa72
data/conf/gem.yaml CHANGED
@@ -1 +1 @@
1
- version: 1.4.0
1
+ version: 2.1.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.
@@ -39,7 +39,7 @@ module RubyAemAws
39
39
  }
40
40
  end
41
41
 
42
- # @param loggroup_name Cloudwatch loggroup name
42
+ # @param log_group_name Cloudwatch loggroup name
43
43
  # @param log_stream_name Cloudwatch logstream name
44
44
  # @return Array of a Cloudwatch log stream filter to filter for a specific Cloudwatch log stream
45
45
  def filter_for_cloudwatch_log_stream(log_group_name, log_stream_name)
@@ -71,7 +71,7 @@ module RubyAemAws
71
71
  end
72
72
 
73
73
  # @param dimensions_name Cloudwatch Dimension name
74
- # @param dimension_values Cloudwatch Dimension value
74
+ # @param dimensions_value Cloudwatch Dimension value
75
75
  # @return Array of a Cloudwatch Dimension value filter for the Cloudwatch dimension filter
76
76
  def dimensions_value_filter_for_cloudwatch_metric(dimensions_name, dimensions_value)
77
77
  {
@@ -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,6 @@ module RubyAemAws
33
33
  filters: [
34
34
  { name: 'tag:StackPrefix', values: [@descriptor.stack_prefix] },
35
35
  { name: 'tag:Component', values: [@descriptor.ec2.component] },
36
- { name: 'tag:Name', values: [@descriptor.ec2.name] },
37
36
  { name: 'instance-state-name', values: ['running'] }
38
37
  ]
39
38
  }
@@ -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.
@@ -35,7 +35,7 @@ module RubyAemAws
35
35
  end
36
36
 
37
37
  # @param dynamodb_tablename AWS DynamoDB table name
38
- # @param attkey_attribute_valueribute_value Key value to query for
38
+ # @param key_attribute_value Key value to query for
39
39
  # @return Array of a DynamoDB filter to query for a specific value
40
40
  def filter_for_db_query(dynamodb_tablename, key_attribute_value)
41
41
  {
@@ -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.
@@ -36,11 +36,6 @@ module RubyAemAws
36
36
  @stack_prefix = stack_prefix
37
37
  end
38
38
 
39
- # @param stack_prefix AWS tag: StackPrefix
40
- # @param consolidated_aws_clients Array of AWS Clients and Resource connections:
41
- # - CloudWatchClient: AWS Cloudwatch Client.
42
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
43
- # - Ec2Resource: AWS EC2 Resource connection.
44
39
  # @return new RubyAemAws::Component::AuthorPublishDispatcher instance
45
40
  def author_publish_dispatcher
46
41
  RubyAemAws::Component::AuthorPublishDispatcher.new(@stack_prefix, @consolidated_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.
@@ -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 = {
@@ -70,69 +70,31 @@ module RubyAemAws
70
70
  @stack_prefix = stack_prefix
71
71
  end
72
72
 
73
- # @param stack_prefix AWS tag: StackPrefix
74
- # @param dispatcher_aws_clients Array of AWS Clients and Resource connections:
75
- # - AutoScalingClient: AWS AutoScalingGroup Client.
76
- # - CloudWatchClient: AWS Cloudwatch Client.
77
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
78
- # - Ec2Resource: AWS EC2 Resource connection.
79
- # - ElbClient: AWS ElasticLoadBalancer Client.
80
73
  # @return new RubyAemAws::Component::AuthorDispatcher instance
81
74
  def author_dispatcher
82
75
  RubyAemAws::Component::AuthorDispatcher.new(@stack_prefix, @dispatcher_aws_clients)
83
76
  end
84
77
 
85
- # @param stack_prefix AWS tag: StackPrefix
86
- # @param author_aws_clients Array of AWS Clients and Resource connections:
87
- # - CloudWatchClient: AWS Cloudwatch Client.
88
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
89
- # - Ec2Resource: AWS EC2 Resource connection.
90
- # - ElbClient: AWS ElasticLoadBalancer Client.
91
78
  # @return new RubyAemAws::Component::Author instance
92
79
  def author
93
80
  RubyAemAws::Component::Author.new(@stack_prefix, @author_aws_clients)
94
81
  end
95
82
 
96
- # @param stack_prefix AWS tag: StackPrefix
97
- # @param chaos_monkey_aws_clients Array of AWS Clients and Resource connections:
98
- # - AutoScalingClient: AWS AutoScalingGroup Client.
99
- # - CloudWatchClient: AWS Cloudwatch Client.
100
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
101
- # - Ec2Resource: AWS EC2 Resource connection.
102
83
  # @return new RubyAemAws::Component::ChaosMonkey instance
103
84
  def chaos_monkey
104
85
  RubyAemAws::Component::ChaosMonkey.new(@stack_prefix, @aem_java_aws_clients)
105
86
  end
106
87
 
107
- # @param stack_prefix AWS tag: StackPrefix
108
- # @param orchestrator_aws_clients Array of AWS Clients and Resource connections:
109
- # - AutoScalingClient: AWS AutoScalingGroup Client.
110
- # - CloudWatchClient: AWS Cloudwatch Client.
111
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
112
- # - Ec2Resource: AWS EC2 Resource connection.
113
88
  # @return new RubyAemAws::Component::Orchestrator instance
114
89
  def orchestrator
115
90
  RubyAemAws::Component::Orchestrator.new(@stack_prefix, @aem_java_aws_clients)
116
91
  end
117
92
 
118
- # @param stack_prefix AWS tag: StackPrefix
119
- # @param publish_aws_clients Array of AWS Clients and Resource connections:
120
- # - AutoScalingClient: AWS AutoScalingGroup Client.
121
- # - CloudWatchClient: AWS Cloudwatch Client.
122
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
123
- # - Ec2Resource: AWS EC2 Resource connection.
124
93
  # @return new RubyAemAws::Component::Publish instance
125
94
  def publish
126
95
  RubyAemAws::Component::Publish.new(@stack_prefix, @publish_aws_clients)
127
96
  end
128
97
 
129
- # @param stack_prefix AWS tag: StackPrefix
130
- # @param dispatcher_aws_clients Array of AWS Clients and Resource connections:
131
- # - AutoScalingClient: AWS AutoScalingGroup Client.
132
- # - CloudWatchClient: AWS Cloudwatch Client.
133
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
134
- # - Ec2Resource: AWS EC2 Resource connection.
135
- # - ElbClient: AWS ElasticLoadBalancer Client.
136
98
  # @return new RubyAemAws::Component::PublishDispatcher instance
137
99
  def publish_dispatcher
138
100
  RubyAemAws::Component::PublishDispatcher.new(@stack_prefix, @dispatcher_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.
@@ -29,7 +29,6 @@ module RubyAemAws
29
29
  include SNSTopic
30
30
  include S3Access
31
31
 
32
- # @param dynamodb_client AWS DynamoDB client connection
33
32
  # @param params Array of AWS Clients and Resource connections:
34
33
  # - CloudWatchClient: AWS Cloudwatch Client.
35
34
  # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
@@ -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
- REGION_DEFAULT = 'ap-southeast-2'.freeze
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']
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']
48
53
  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.
@@ -43,13 +43,6 @@ module RubyAemAws
43
43
 
44
44
  # Raise this when a component unexpectedly has more than one instance.
45
45
  class ExpectedSingleInstanceError < StandardError
46
- # def initialize(count, descriptor)
47
- # message << 'Expected exactly one instance'
48
- # message << " but got #{count}" unless count.nil?
49
- # message << "for (#{descriptor.stack_prefix}, #{descriptor.ec2.component}, #{descriptor.ec2.name})" unless descriptor.nil?
50
- # super(message)
51
- # end
52
-
53
46
  def initialize(msg = 'Expected exactly one instance')
54
47
  super
55
48
  end
@@ -60,7 +53,7 @@ module RubyAemAws
60
53
  def initialize(msg = "No credentials found!
61
54
  Set environment variable AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or AWS_PROFILE.
62
55
  Alternative use following syntax:
63
- 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
64
57
  RubyAemAws::AemAws.new(credentials_profile_name)")
65
58
  super
66
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.
@@ -170,7 +170,7 @@ module RubyAemAws
170
170
  return true unless response.events.empty?
171
171
  end
172
172
 
173
- # @param loggroup Cloudwatch loggroup name
173
+ # @param loggroup_name Cloudwatch loggroup name
174
174
  # @return True if Cloudwatch loggroup exists
175
175
  def loggroup?(loggroup_name)
176
176
  namespace = 'AWS/Logs'
@@ -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.
@@ -20,20 +20,21 @@ module RubyAemAws
20
20
  # AemAws class represents the AWS stack for AEM.
21
21
  class AemAws
22
22
  # @param conf configuration hash of the following configuration values:
23
- # - region: the AWS region (eg ap-southeast-2)
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
26
  # - aws_profile: AWS profile name
27
27
  # @return new RubyAemAws::AemAws instance
28
28
  def initialize(conf = {})
29
- conf[:region] ||= Constants::REGION_DEFAULT
29
+ conf[:aws_region] ||= Constants::REGION_DEFAULT
30
30
  conf[:aws_access_key_id] ||= Constants::ACCESS_KEY_ID
31
31
  conf[:aws_secret_access_key] ||= Constants::SECRET_ACCESS_KEY
32
+ conf[:aws_session_token] ||= Constants::SESSION_TOKEN
32
33
  conf[:aws_profile] ||= Constants::PROFILE
33
34
 
34
- Aws.config.update(region: conf[:region])
35
+ Aws.config.update(region: conf[:aws_region])
35
36
 
36
- credentials = Aws::Credentials.new(conf[:aws_access_key_id], conf[:aws_secret_access_key]) unless conf[:aws_access_key_id].nil?
37
+ 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
38
  credentials = Aws::SharedCredentials.new(profile_name: conf[:aws_profile]) unless conf[:aws_profile].nil?
38
39
  credentials = Aws::InstanceProfileCredentials.new if conf[:aws_profile].nil? && conf[:aws_access_key_id].nil?
39
40
  raise RubyAemAws::ArgumentError unless defined? credentials
@@ -58,11 +59,6 @@ module RubyAemAws
58
59
  # Create a consolidated instance.
59
60
  #
60
61
  # @param stack_prefix AWS tag: StackPrefix
61
- # @param aws_clients Array of AWS Clients and Resource connections:
62
- # - CloudFormationClient: AWS Cloudformation Client.
63
- # - CloudWatchClient: AWS Cloudwatch Client.
64
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
65
- # - Ec2Resource: AWS EC2 Resource connection.
66
62
  # @return new RubyAemAws::ConsolidatedStack instance
67
63
  def consolidated(stack_prefix)
68
64
  aws_clients = {
@@ -78,13 +74,6 @@ module RubyAemAws
78
74
  # Create a full set instance.
79
75
  #
80
76
  # @param stack_prefix AWS tag: StackPrefix
81
- # @param aws_clients Array of AWS Clients and Resource connections:
82
- # - AutoScalingClient: AWS AutoScalingGroup Client.
83
- # - CloudFormationClient: AWS Cloudformation Client.
84
- # - CloudWatchClient: AWS Cloudwatch Client.
85
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
86
- # - Ec2Resource: AWS EC2 Resource connection.
87
- # - ElbClient: AWS ElasticLoadBalancer Client.
88
77
  # @return new RubyAemAws::FullSetStack instance
89
78
  def full_set(stack_prefix)
90
79
  aws_clients = {
@@ -102,13 +91,6 @@ module RubyAemAws
102
91
  # Create Stack Manager resources
103
92
  #
104
93
  # @param stack_prefix AWS tag: StackPrefix
105
- # @param aws_clients Array of AWS Clients and Resource connections:
106
- # - CloudFormationClient: AWS Cloudformation Client.
107
- # - CloudWatchClient: AWS Cloudwatch Client.
108
- # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
109
- # - DynamoDBClient: AWS DynamoDB Client.
110
- # - S3Client: AWS S3 Client.
111
- # - S3Resource: AWS S3 Resource connection.
112
94
  # @return new RubyAemAws::StackManager instance
113
95
  def stack_manager(stack_prefix)
114
96
  aws_clients = {
@@ -130,7 +112,7 @@ module RubyAemAws
130
112
  {
131
113
  Ec2Client: Aws::EC2::Client.new,
132
114
  Ec2Resource: Aws::EC2::Resource.new,
133
- ElbClient: Aws::ElasticLoadBalancing::Client.new(
115
+ ElbClient: Aws::ElasticLoadBalancingV2::Client.new(
134
116
  retry_limit: 20
135
117
  ),
136
118
  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.4.0
4
+ version: 2.1.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: 2019-08-14 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk