ruby_aem_aws 0.9.3 → 1.0.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/lib/ruby_aem_aws/abstract/cloudwatch.rb +81 -0
  3. data/lib/ruby_aem_aws/{component/abstract_component.rb → abstract/component.rb} +4 -2
  4. data/lib/ruby_aem_aws/{component/abstract_grouped_component.rb → abstract/grouped_component.rb} +1 -1
  5. data/lib/ruby_aem_aws/{component/abstract_single_component.rb → abstract/single_component.rb} +1 -1
  6. data/lib/ruby_aem_aws/{component/abstract_snapshot.rb → abstract/snapshot.rb} +1 -1
  7. data/lib/ruby_aem_aws/{component/abstract_stackmanager.rb → abstract/stackmanager.rb} +10 -0
  8. data/lib/ruby_aem_aws/{consolidated_stack.rb → architecture/consolidated_stack.rb} +21 -7
  9. data/lib/ruby_aem_aws/architecture/full_set_stack.rb +141 -0
  10. data/lib/ruby_aem_aws/architecture/stack_manager.rb +44 -0
  11. data/lib/ruby_aem_aws/client/cloudwatch.rb +87 -0
  12. data/lib/ruby_aem_aws/{component/mixins → client}/dynamo_db.rb +0 -0
  13. data/lib/ruby_aem_aws/{component/mixins → client}/s3.rb +1 -1
  14. data/lib/ruby_aem_aws/{component/mixins → client}/sns_topic.rb +0 -0
  15. data/lib/ruby_aem_aws/component/author.rb +16 -8
  16. data/lib/ruby_aem_aws/component/author_dispatcher.rb +19 -16
  17. data/lib/ruby_aem_aws/component/author_primary.rb +14 -11
  18. data/lib/ruby_aem_aws/component/author_publish_dispatcher.rb +14 -12
  19. data/lib/ruby_aem_aws/component/author_standby.rb +14 -12
  20. data/lib/ruby_aem_aws/component/chaos_monkey.rb +16 -13
  21. data/lib/ruby_aem_aws/component/orchestrator.rb +16 -13
  22. data/lib/ruby_aem_aws/component/publish.rb +17 -15
  23. data/lib/ruby_aem_aws/component/publish_dispatcher.rb +19 -16
  24. data/lib/ruby_aem_aws/component/stack_manager_resources.rb +19 -11
  25. data/lib/ruby_aem_aws/error.rb +7 -0
  26. data/lib/ruby_aem_aws/mixins/healthy_count_verifier.rb +148 -0
  27. data/lib/ruby_aem_aws/{component/mixins/healthy_count_verifier.rb → mixins/healthy_resource_verifier.rb} +29 -43
  28. data/lib/ruby_aem_aws/{component/mixins → mixins}/healthy_state_verifier.rb +1 -1
  29. data/lib/ruby_aem_aws/{component/mixins → mixins}/instance_describer.rb +0 -0
  30. data/lib/ruby_aem_aws/mixins/metric_verifier.rb +186 -0
  31. data/lib/ruby_aem_aws/{component/mixins → mixins}/snapshot_verifier.rb +0 -0
  32. data/lib/ruby_aem_aws.rb +60 -19
  33. metadata +21 -18
  34. data/lib/ruby_aem_aws/component/mixins/metric_verifier.rb +0 -43
  35. data/lib/ruby_aem_aws/full_set_stack.rb +0 -69
  36. data/lib/ruby_aem_aws/stack_manager.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d23d001d09dd996630598d0071f708718f30b0b
4
- data.tar.gz: c5cefe20a38f77314d6cbeed3f9ed8cb388d7f56
3
+ metadata.gz: 3daf08867a182eb7c35e8ed5ebcfb53e7bb389a5
4
+ data.tar.gz: 6da14e3a85100aa7a00f101ce126bd58e1eab7b8
5
5
  SHA512:
6
- metadata.gz: 63fb90c45359a8f53ce46f3915b4db065af656a8191580737ecce6c63021d5ac6e1976700ec7cac4a68ce5965763431d44a5c93b60bb2885eff2cf8da8173249
7
- data.tar.gz: ebbedfd91b882d848d4e02380fa385bd49a9c850b4f401fbab62df3870f7d98bbb28b8f2e23064e0360346427d46f6a41944940b835c8d6d9de7e2224e2fa722
6
+ metadata.gz: 5684eeab58ef11ff2eb70f7478f2ca52f56d1402119c5c96ef81f44981dfd14347cdb91e673191a68864e0657d9ff06d7577007a382f4ff6d937233429c46a1d
7
+ data.tar.gz: f21329b8af855fdec77baa94587f9fafd1f593ca5687365bab749ad92f5d879ed486f33dbf7ed0804261ff2807b32967fe3b5dde909bc429894aa4d5823b5877
@@ -0,0 +1,81 @@
1
+ # Copyright 2018 Shine Solutions
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative '../error'
16
+
17
+ module RubyAemAws
18
+ # Add common methods to all Components.
19
+ module AbstractCloudwatch
20
+ # @param alarm_name Cloudwatch alarm name
21
+ # @return Array of a Cloudwatch alarm filter to filter for a specific Cloudwatch alarm
22
+ private def filter_for_cloudwatch_alarm(alarm_name)
23
+ {
24
+ alarm_names: [alarm_name]
25
+ }
26
+ end
27
+
28
+ # @param loggroup_name Cloudwatch loggroup name
29
+ # @param log_stream_name Cloudwatch logstream name
30
+ # @param log_message log message to filter for
31
+ # @return Array of a Cloudwatch log event filter to filter for a specific Cloudwatch log event
32
+ private def filter_for_cloudwatch_log_event(loggroup_name, log_stream_name, log_message)
33
+ {
34
+ log_group_name: loggroup_name,
35
+ log_stream_names: [log_stream_name],
36
+ filter_pattern: log_message
37
+ }
38
+ end
39
+
40
+ # @param loggroup_name Cloudwatch loggroup name
41
+ # @param log_stream_name Cloudwatch logstream name
42
+ # @return Array of a Cloudwatch log stream filter to filter for a specific Cloudwatch log stream
43
+ private def filter_for_cloudwatch_log_stream(log_group_name, log_stream_name)
44
+ {
45
+ log_group_name: log_group_name,
46
+ log_stream_name_prefix: log_stream_name,
47
+ order_by: 'LogStreamName'
48
+ }
49
+ end
50
+
51
+ # @param namespace Cloudwatch metric namespace
52
+ # @param metric_name Cloudwatch metric name
53
+ # @return Array of a Cloudwatch metric filter to filter for a specific Cloudwatch metric
54
+ private def filter_for_cloudwatch_metric(namespace, metric_name)
55
+ {
56
+ namespace: namespace,
57
+ metric_name: metric_name
58
+ }
59
+ end
60
+
61
+ # @param dimension_values Cloudwatch Dimension value
62
+ # @return Array of a Cloudwatch dimension filter for the Cloudwatch metric filter
63
+ private def dimensions_filter_for_cloudwatch_metric(dimension_values)
64
+ {
65
+ dimensions: [
66
+ dimension_values
67
+ ]
68
+ }
69
+ end
70
+
71
+ # @param dimensions_name Cloudwatch Dimension name
72
+ # @param dimension_values Cloudwatch Dimension value
73
+ # @return Array of a Cloudwatch Dimension value filter for the Cloudwatch dimension filter
74
+ private def dimensions_value_filter_for_cloudwatch_metric(dimensions_name, dimensions_value)
75
+ {
76
+ name: dimensions_name,
77
+ value: dimensions_value
78
+ }
79
+ end
80
+ end
81
+ end
@@ -12,8 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'component_descriptor'
16
- require_relative 'mixins/instance_describer'
15
+ require_relative '../component/component_descriptor'
16
+ require_relative '../mixins/instance_describer'
17
17
  require_relative '../error'
18
18
 
19
19
  module RubyAemAws
@@ -36,6 +36,8 @@ module RubyAemAws
36
36
  }
37
37
  end
38
38
 
39
+ # @param snapshot_type SnapshotType tag
40
+ # @return Array of a EC2 filter to filter for a specific Snapshottype
39
41
  private def filter_for_snapshot(snapshot_type)
40
42
  {
41
43
  filters: [
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'aws-sdk'
16
- require_relative 'abstract_component'
16
+ require_relative 'component'
17
17
 
18
18
  module RubyAemAws
19
19
  # Add common methods to all Components.
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'aws-sdk'
16
- require_relative 'abstract_component'
16
+ require_relative 'component'
17
17
 
18
18
  module RubyAemAws
19
19
  # Add common methods to all Components.
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'aws-sdk'
16
- require_relative 'abstract_component'
16
+ require_relative 'component'
17
17
 
18
18
  module RubyAemAws
19
19
  # Add method to scan for snapshots
@@ -15,6 +15,9 @@
15
15
  module RubyAemAws
16
16
  # Add common methods to StackManager resource
17
17
  module AbstractStackManager
18
+ # @param dynamodb_tablename AWS DynamoDB table name
19
+ # @param attribute_value value to scan for
20
+ # @return Array of a DynamoDB filter to scan for a specific value
18
21
  private def filter_for_db_scan(dynamodb_tablename, attribute_value)
19
22
  {
20
23
  table_name: dynamodb_tablename,
@@ -29,6 +32,9 @@ module RubyAemAws
29
32
  }
30
33
  end
31
34
 
35
+ # @param dynamodb_tablename AWS DynamoDB table name
36
+ # @param attkey_attribute_valueribute_value Key value to query for
37
+ # @return Array of a DynamoDB filter to query for a specific value
32
38
  private def filter_for_db_query(dynamodb_tablename, key_attribute_value)
33
39
  {
34
40
  table_name: dynamodb_tablename,
@@ -49,6 +55,10 @@ module RubyAemAws
49
55
  }
50
56
  end
51
57
 
58
+ # @param task Stack Manager task to trigger
59
+ # @param stack_prefix Target Stack Prefix name
60
+ # @param details SNS Message payload
61
+ # @return Array of a AWS SNS publish filter to query for a specific value
52
62
  private def message_for_sns_publish(task, stack_prefix, details)
53
63
  "{ \"default\": \"{ 'task': '#{task}', 'stack_prefix': '#{stack_prefix}', 'details': #{details} }\"}"
54
64
  end
@@ -12,24 +12,38 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'component/author_publish_dispatcher'
15
+ require_relative '../component/author_publish_dispatcher'
16
16
 
17
17
  module RubyAemAws
18
18
  # Factory for the consolidated AEM stack component interface.
19
19
  class ConsolidatedStack
20
+ attr_reader :cloudformation_client
21
+
20
22
  # @param stack_prefix AWS tag: StackPrefix
21
- # @param ec2_resource AWS EC2 client
22
- # @param cloud_watch_client AWS CloudWatch client
23
+ # @param params Array of AWS Clients and Resource connections:
24
+ # - CloudFormationClient: AWS Cloudformation Client.
25
+ # - CloudWatchClient: AWS Cloudwatch Client.
26
+ # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
27
+ # - Ec2Resource: AWS EC2 Resource connection.
23
28
  # @return new RubyAemAws::ConsolidatedStack instance
24
- def initialize(stack_prefix, ec2_resource, cloud_watch_client)
29
+ def initialize(stack_prefix, params)
30
+ @consolidated_aws_clients = {
31
+ CloudWatchClient: params[:CloudWatchClient],
32
+ CloudWatchLogsClient: params[:CloudWatchLogsClient],
33
+ Ec2Resource: params[:Ec2Resource]
34
+ }
35
+ @cloudformation_client = cloudformation_client
25
36
  @stack_prefix = stack_prefix
26
- @ec2_resource = ec2_resource
27
- @cloud_watch_client = cloud_watch_client
28
37
  end
29
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.
30
44
  # @return new RubyAemAws::Component::AuthorPublishDispatcher instance
31
45
  def author_publish_dispatcher
32
- RubyAemAws::Component::AuthorPublishDispatcher.new(@stack_prefix, @ec2_resource, @cloud_watch_client)
46
+ RubyAemAws::Component::AuthorPublishDispatcher.new(@stack_prefix, @consolidated_aws_clients)
33
47
  end
34
48
  end
35
49
  end
@@ -0,0 +1,141 @@
1
+ # Copyright 2018 Shine Solutions
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative '../component/author_dispatcher'
16
+ require_relative '../component/author'
17
+ require_relative '../component/chaos_monkey'
18
+ require_relative '../component/orchestrator'
19
+ require_relative '../component/publish_dispatcher'
20
+ require_relative '../component/publish'
21
+ require_relative '../mixins/metric_verifier'
22
+
23
+ module RubyAemAws
24
+ # Factory for the full-set AEM stack component interfaces.
25
+ class FullSetStack
26
+ attr_reader :cloudformation_client, :cloud_watch_client
27
+ include MetricVerifier
28
+
29
+ # @param stack_prefix AWS tag: StackPrefix
30
+ # @param params Array of AWS Clients and Resource connections:
31
+ # - AutoScalingClient: AWS AutoScalingGroup Client.
32
+ # - CloudFormationClient: AWS Cloudformation Client.
33
+ # - CloudWatchClient: AWS Cloudwatch Client.
34
+ # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
35
+ # - Ec2Resource: AWS EC2 Resource connection.
36
+ # - ElbClient: AWS ElasticLoadBalancer Client.
37
+ # @return new RubyAemAws::FullSetStack instance
38
+ def initialize(stack_prefix, params)
39
+ @author_aws_clients = {
40
+ CloudWatchClient: params[:CloudWatchClient],
41
+ CloudWatchLogsClient: params[:CloudWatchLogsClient],
42
+ Ec2Resource: params[:Ec2Resource],
43
+ ElbClient: params[:ElbClient]
44
+ }
45
+
46
+ @dispatcher_aws_clients = {
47
+ AutoScalingClient: params[:AutoScalingClient],
48
+ CloudWatchClient: params[:CloudWatchClient],
49
+ CloudWatchLogsClient: params[:CloudWatchLogsClient],
50
+ Ec2Resource: params[:Ec2Resource],
51
+ ElbClient: params[:ElbClient]
52
+ }
53
+
54
+ @publish_aws_clients = {
55
+ AutoScalingClient: params[:AutoScalingClient],
56
+ CloudWatchClient: params[:CloudWatchClient],
57
+ CloudWatchLogsClient: params[:CloudWatchLogsClient],
58
+ Ec2Resource: params[:Ec2Resource]
59
+ }
60
+
61
+ @aem_java_aws_clients = {
62
+ AutoScalingClient: params[:AutoScalingClient],
63
+ CloudWatchClient: params[:CloudWatchClient],
64
+ CloudWatchLogsClient: params[:CloudWatchLogsClient],
65
+ Ec2Resource: params[:Ec2Resource]
66
+ }
67
+
68
+ @cloudformation_client = params[:CloudFormationClient]
69
+ @cloud_watch_client = params[:CloudWatchClient]
70
+ @stack_prefix = stack_prefix
71
+ end
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
+ # @return new RubyAemAws::Component::AuthorDispatcher instance
81
+ def author_dispatcher
82
+ RubyAemAws::Component::AuthorDispatcher.new(@stack_prefix, @dispatcher_aws_clients)
83
+ end
84
+
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
+ # @return new RubyAemAws::Component::Author instance
92
+ def author
93
+ RubyAemAws::Component::Author.new(@stack_prefix, @author_aws_clients)
94
+ end
95
+
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
+ # @return new RubyAemAws::Component::ChaosMonkey instance
103
+ def chaos_monkey
104
+ RubyAemAws::Component::ChaosMonkey.new(@stack_prefix, @aem_java_aws_clients)
105
+ end
106
+
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
+ # @return new RubyAemAws::Component::Orchestrator instance
114
+ def orchestrator
115
+ RubyAemAws::Component::Orchestrator.new(@stack_prefix, @aem_java_aws_clients)
116
+ end
117
+
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
+ # @return new RubyAemAws::Component::Publish instance
125
+ def publish
126
+ RubyAemAws::Component::Publish.new(@stack_prefix, @publish_aws_clients)
127
+ end
128
+
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
+ # @return new RubyAemAws::Component::PublishDispatcher instance
137
+ def publish_dispatcher
138
+ RubyAemAws::Component::PublishDispatcher.new(@stack_prefix, @dispatcher_aws_clients)
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,44 @@
1
+ # Copyright 2018 Shine Solutions
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative '../component/stack_manager_resources'
16
+
17
+ module RubyAemAws
18
+ # Interface to interact with AEM StackManager
19
+ class StackManager
20
+ attr_reader :sm_resources, :cloudformation_client
21
+ # @param stack_prefix AWS tag: StackPrefix
22
+ # @param params Array of AWS Clients and Resource connections:
23
+ # - CloudFormationClient: AWS Cloudformation Client.
24
+ # - CloudWatchClient: AWS Cloudwatch Client.
25
+ # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
26
+ # - DynamoDBClient: AWS DynamoDB Client.
27
+ # - S3Client: AWS S3 Client.
28
+ # - S3Resource: AWS S3 Resource connection.
29
+ # @return new RubyAemAws::StackManager instance
30
+ def initialize(stack_prefix, params)
31
+ stack_manager_aws_client = {
32
+ CloudWatchClient: params[:CloudWatchClient],
33
+ CloudWatchLogsClient: params[:CloudWatchLogsClient],
34
+ DynamoDBClient: params[:DynamoDBClient],
35
+ S3Client: params[:S3Client],
36
+ S3Resource: params[:S3Resource]
37
+ }
38
+
39
+ @sm_resources = RubyAemAws::Component::StackManagerResources.new(stack_manager_aws_client)
40
+ @cloudformation_client = params[:CloudFormationClient]
41
+ @stack_prefix = stack_prefix
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,87 @@
1
+ # Copyright 2018 Shine Solutions
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module RubyAemAws
16
+ # Mixin for checking that an instance has associated CloudWatch metrics.
17
+ module CloudwatchClient
18
+ # @param alarm_name Cloudwatch alarm name
19
+ # @return Cloudwatch client describe_alarms response
20
+ def get_alarm(alarm_name)
21
+ alarm_filter = filter_for_cloudwatch_alarm(alarm_name)
22
+
23
+ response = cloud_watch_client.describe_alarms(alarm_filter)
24
+
25
+ until response.next_token.nil?
26
+ next_token = { next_token: response.next_token }
27
+ filter.update(next_token)
28
+ response = cloud_watch_client.describe_alarms(alarm_filter)
29
+ end
30
+
31
+ response
32
+ end
33
+
34
+ # @param loggroup_name Cloudwatch loggroup name
35
+ # @param log_stream_name Cloudwatch log stream name
36
+ # @param log_message Log message to filter for
37
+ # @return Cloudwatch log client filter_log_events response
38
+ def get_log_event(loggroup_name, log_stream_name, log_message)
39
+ filter = filter_for_cloudwatch_log_event(loggroup_name, log_stream_name, log_message)
40
+ response = cloud_watch_log_client.filter_log_events(filter)
41
+
42
+ until response.next_token.nil?
43
+ next_token = { next_token: response.next_token }
44
+ filter.update(next_token)
45
+ response = cloud_watch_client.filter_log_events(filter)
46
+ end
47
+
48
+ response
49
+ end
50
+
51
+ # @param loggroup_name Cloudwatch loggroup name
52
+ # @param log_stream_name Cloudwatch log stream name
53
+ # @return Cloudwatch log client describe_log_streams response
54
+ def get_log_streams(loggroup_name, log_stream_name)
55
+ filter = filter_for_cloudwatch_log_stream(loggroup_name, log_stream_name)
56
+
57
+ response = cloud_watch_log_client.describe_log_streams(filter)
58
+
59
+ until response.next_token.nil?
60
+ next_token = { next_token: response.next_token }
61
+ filter.update(next_token)
62
+ response = cloud_watch_client.describe_log_streams(filter)
63
+ end
64
+
65
+ response
66
+ end
67
+
68
+ # @param namespace Cloudwatch namespace name
69
+ # @param metric_name Cloudwatch metric name
70
+ # @param dimension Cloudwatch dimension filter
71
+ # @return Cloudwatch client list_metrics response
72
+ def get_metrics(namespace, metric_name, dimension)
73
+ filter = filter_for_cloudwatch_metric(namespace, metric_name)
74
+ filter.update(dimension)
75
+
76
+ response = cloud_watch_client.list_metrics(filter)
77
+
78
+ until response.next_token.nil?
79
+ next_token = { next_token: response.next_token }
80
+ filter.update(next_token)
81
+ response = cloud_watch_client.list_metrics(filter)
82
+ end
83
+
84
+ response
85
+ end
86
+ end
87
+ end
@@ -36,7 +36,7 @@ module RubyAemAws
36
36
  def get_s3_object(bucket, s3_object_name, dest_path)
37
37
  options = { bucket: bucket, key: s3_object_name }
38
38
  options = options.merge(response_target: dest_path) unless dest_path.nil?
39
- s3_client.get_object(**options)
39
+ s3_client.get_object(options)
40
40
  end
41
41
  end
42
42
  end
@@ -25,15 +25,23 @@ module RubyAemAws
25
25
  ELB_NAME = 'AEM Author Load Balancer'.freeze
26
26
 
27
27
  # @param stack_prefix AWS tag: StackPrefix
28
- # @param ec2_resource AWS EC2 resource
29
- # @param elb_client AWS ELB client
30
- # @param cloud_watch_client AWS CloudWatch client
28
+ # @param params Array of AWS Clients and Resource connections:
29
+ # - CloudWatchClient: AWS Cloudwatch Client.
30
+ # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
31
+ # - Ec2Resource: AWS EC2 Resource connection.
32
+ # - ElbClient: AWS ElasticLoadBalancer Client.
31
33
  # @return new RubyAemAws::FullSet::Author
32
- def initialize(stack_prefix, ec2_resource, elb_client, cloud_watch_client)
33
- @author_primary = Component::AuthorPrimary.new(stack_prefix, ec2_resource, cloud_watch_client)
34
- @author_standby = Component::AuthorStandby.new(stack_prefix, ec2_resource, cloud_watch_client)
35
- @ec2_resource = ec2_resource
36
- @elb_client = elb_client
34
+ def initialize(stack_prefix, params)
35
+ author_aws_clients = {
36
+ CloudWatchClient: params[:CloudWatchClient],
37
+ CloudWatchLogsClient: params[:CloudWatchLogsClient],
38
+ Ec2Resource: params[:Ec2Resource]
39
+ }
40
+
41
+ @author_primary = Component::AuthorPrimary.new(stack_prefix, author_aws_clients)
42
+ @author_standby = Component::AuthorStandby.new(stack_prefix, author_aws_clients)
43
+ @ec2_resource = params[:Ec2Resource]
44
+ @elb_client = params[:ElbClient]
37
45
  end
38
46
 
39
47
  # @return true, if all author instances are healthy
@@ -12,21 +12,21 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'abstract_grouped_component'
16
- require_relative 'abstract_snapshot'
17
- require_relative 'mixins/healthy_count_verifier'
18
- require_relative 'mixins/metric_verifier'
15
+ require_relative '../abstract/grouped_component'
16
+ require_relative '../abstract/snapshot'
17
+ require_relative '../mixins/healthy_resource_verifier'
18
+ require_relative '../mixins/metric_verifier'
19
19
  require_relative 'component_descriptor'
20
- require_relative 'mixins/snapshot_verifier'
20
+ require_relative '../mixins/snapshot_verifier'
21
21
 
22
22
  module RubyAemAws
23
23
  module Component
24
24
  # Interface to the AWS instances playing and supporting the AuthorDispatcher role in a full-set AEM stack.
25
25
  class AuthorDispatcher
26
- attr_reader :descriptor, :ec2_resource, :asg_client, :elb_client, :cloud_watch_client
26
+ attr_reader :descriptor, :ec2_resource, :asg_client, :elb_client, :cloud_watch_client, :cloud_watch_log_client
27
27
  include AbstractGroupedComponent
28
28
  include AbstractSnapshot
29
- include HealthyCountVerifier
29
+ include HealthyResourceVerifier
30
30
  include MetricVerifier
31
31
  include SnapshotVerifier
32
32
 
@@ -36,19 +36,22 @@ module RubyAemAws
36
36
  ELB_NAME = 'AEM Author Dispatcher Load Balancer'.freeze
37
37
 
38
38
  # @param stack_prefix AWS tag: StackPrefix
39
- # @param ec2_resource AWS EC2 resource
40
- # @param asg_client AWS AutoScalingGroup client
41
- # @param elb_client AWS ElasticLoadBalancer client
42
- # @param cloud_watch_client AWS CloudWatch client
39
+ # @param params Array of AWS Clients and Resource connections:
40
+ # - AutoScalingClient: AWS AutoScalingGroup Client.
41
+ # - CloudWatchClient: AWS Cloudwatch Client.
42
+ # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
43
+ # - Ec2Resource: AWS EC2 Resource connection.
44
+ # - ElbClient: AWS ElasticLoadBalancer Client.
43
45
  # @return new RubyAemAws::FullSet::AuthorDispatcher
44
- def initialize(stack_prefix, ec2_resource, asg_client, elb_client, cloud_watch_client)
46
+ def initialize(stack_prefix, params)
45
47
  @descriptor = ComponentDescriptor.new(stack_prefix,
46
48
  EC2Descriptor.new(EC2_COMPONENT, EC2_NAME),
47
49
  ELBDescriptor.new(ELB_ID, ELB_NAME))
48
- @ec2_resource = ec2_resource
49
- @elb_client = elb_client
50
- @asg_client = asg_client
51
- @cloud_watch_client = cloud_watch_client
50
+ @asg_client = params[:AutoScalingClient]
51
+ @cloud_watch_client = params[:CloudWatchClient]
52
+ @cloud_watch_log_client = params[:CloudWatchLogsClient]
53
+ @ec2_resource = params[:Ec2Resource]
54
+ @elb_client = params[:ElbClient]
52
55
  end
53
56
 
54
57
  def terminate_all_instances
@@ -12,17 +12,17 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'abstract_single_component'
16
- require_relative 'abstract_snapshot'
17
- require_relative 'mixins/healthy_state_verifier'
18
- require_relative 'mixins/metric_verifier'
19
- require_relative 'mixins/snapshot_verifier'
15
+ require_relative '../abstract/single_component'
16
+ require_relative '../abstract/snapshot'
17
+ require_relative '../mixins/healthy_state_verifier'
18
+ require_relative '../mixins/metric_verifier'
19
+ require_relative '../mixins/snapshot_verifier'
20
20
 
21
21
  module RubyAemAws
22
22
  module Component
23
23
  # Interface to the AWS instance running the Author-Primary component of a full-set AEM stack.
24
24
  class AuthorPrimary
25
- attr_reader :descriptor, :ec2_resource, :cloud_watch_client
25
+ attr_reader :descriptor, :ec2_resource, :cloud_watch_client, :cloud_watch_log_client
26
26
  include AbstractSingleComponent
27
27
  include AbstractSnapshot
28
28
  include HealthyStateVerifier
@@ -33,14 +33,17 @@ module RubyAemAws
33
33
  EC2_NAME = 'AEM Author - Primary'.freeze
34
34
 
35
35
  # @param stack_prefix AWS tag: StackPrefix
36
- # @param ec2_resource AWS EC2 resource
37
- # @param cloud_watch_client AWS CloudWatch client
36
+ # @param params Array of AWS Clients and Resource connections:
37
+ # - CloudWatchClient: AWS Cloudwatch Client.
38
+ # - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
39
+ # - Ec2Resource: AWS EC2 Resource connection.
38
40
  # @return new RubyAemAws::FullSet::AuthorPrimary
39
- def initialize(stack_prefix, ec2_resource, cloud_watch_client)
41
+ def initialize(stack_prefix, params)
40
42
  @descriptor = ComponentDescriptor.new(stack_prefix,
41
43
  EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
42
- @ec2_resource = ec2_resource
43
- @cloud_watch_client = cloud_watch_client
44
+ @cloud_watch_client = params[:CloudWatchClient]
45
+ @cloud_watch_log_client = params[:CloudWatchLogsClient]
46
+ @ec2_resource = params[:Ec2Resource]
44
47
  end
45
48
 
46
49
  # @return Aws::EC2::Instance