This repository has been archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
marbot-elastic-beanstalk.yml
208 lines (208 loc) · 8.17 KB
/
marbot-elastic-beanstalk.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
# Copyright widdix GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
AWSTemplateFormatVersion: '2010-09-09'
Description: 'marbot.io: Elastic Beanstalk monitoring (don''t forget to put the https://github.com/marbot-io/monitoring-jump-start/blob/master/marbot-elastic-beanstalk.config file into your .ebextensions folder; https://github.com/marbot-io/monitoring-jump-start)'
Metadata:
'AWS::CloudFormation::Interface':
ParameterGroups:
- Label:
default: 'marbot endpoint'
Parameters:
- EndpointId
- Stage
- Label:
default: 'Elastic Beanstalk status changes'
Parameters:
- ElasticBeanstalkResourceStatusChange
- OtherResourceStatusChange
- HealthStatusChange
- ManagedUpdateStatusChange
- Label:
default: 'Elastic Beanstalk severities'
Parameters:
- InfoSeverity
- WarnSeverity
- ErrorSeverity
- Label:
default: 'Elastic Beanstalk applications and environments'
Parameters:
- ApplicationNames
- EnvironmentNames
Parameters:
EndpointId:
Description: 'Your marbot endpoint ID (to get this value: select a channel where marbot belongs to and send a message like this: "@marbot show me my endpoint id").'
Type: String
Stage:
Description: 'marbot stage (never change this!).'
Type: String
Default: v1
AllowedValues: [v1, dev]
ElasticBeanstalkResourceStatusChange:
Description: 'Do you want to get notified about Elastic Beanstalk resource status changes (e.g., environment?'
Type: String
Default: true
AllowedValues: [true, false]
OtherResourceStatusChange:
Description: 'Do you want to get notified about other resource status changes (e.g., Auto Scaling Group, Instance, ...)?'
Type: String
Default: true
AllowedValues: [true, false]
HealthStatusChange:
Description: 'Do you want to get notified about health status changes?'
Type: String
Default: true
AllowedValues: [true, false]
ManagedUpdateStatusChange:
Description: 'Do you want to get notified about managed update health status changes?'
Type: String
Default: true
AllowedValues: [true, false]
InfoSeverity:
Description: 'Do you want to receive status changes with severity INFO'
Type: String
Default: true
AllowedValues: [true, false]
WarnSeverity:
Description: 'Do you want to receive status changes with severity WARN'
Type: String
Default: true
AllowedValues: [true, false]
ErrorSeverity:
Description: 'Do you want to receive status changes with severity ERROR'
Type: String
Default: true
AllowedValues: [true, false]
ApplicationNames:
Description: 'Which applications do you want to monitor? Use * to monitor all environments in the region.'
Type: CommaDelimitedList
Default: '*'
EnvironmentNames:
Description: 'Which environments do you want to monitor? Use * to monitor all environments in the region.'
Type: CommaDelimitedList
Default: '*'
Conditions:
ElasticBeanstalkResourceStatusChangeEnabled: !Equals [!Ref ElasticBeanstalkResourceStatusChange, 'true']
OtherResourceStatusChangeEnabled: !Equals [!Ref OtherResourceStatusChange, 'true']
HealthStatusChangeEnabled: !Equals [!Ref HealthStatusChange, 'true']
ManagedUpdateStatusChangeEnabled: !Equals [!Ref ManagedUpdateStatusChange, 'true']
InfoSeverityEnabled: !Equals [!Ref InfoSeverity, 'true']
WarnSeverityEnabled: !Equals [!Ref WarnSeverity, 'true']
ErrorSeverityEnabled: !Equals [!Ref ErrorSeverity, 'true']
ApplicationNamesAll: !Equals [!Join ['', !Ref ApplicationNames], '*']
EnvironmentNamesAll: !Equals [!Join ['', !Ref EnvironmentNames], '*']
Resources:
##########################################################################
# #
# API #
# #
##########################################################################
ApiConnection:
Type: 'AWS::Events::Connection'
Properties:
AuthorizationType: 'API_KEY'
AuthParameters:
ApiKeyAuthParameters:
ApiKeyName: 'X-API-Key'
ApiKeyValue: !Ref EndpointId
Description: 'marbot'
ApiDestination:
Type: 'AWS::Events::ApiDestination'
Properties:
ConnectionArn: !GetAtt 'ApiConnection.Arn'
Description: 'Forwards notifiations and alarms to marbot'
HttpMethod: 'POST'
InvocationEndpoint: !Sub 'https://api.marbot.io/${Stage}/endpoint/${EndpointId}'
InvocationRateLimitPerSecond: 1
ApiRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Principal:
Service:
- 'events.amazonaws.com'
Action:
- sts:AssumeRole
Path: '/service-role/'
Policies:
- PolicyName: eventbridge
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Action: 'events:InvokeApiDestination'
Resource: !GetAtt 'ApiDestination.Arn'
MonitoringJumpStartEvent:
Type: 'AWS::Events::Rule'
Properties:
Description: 'Monitoring Jump Start connection. (created by marbot)'
ScheduleExpression: 'rate(30 days)'
State: ENABLED
Targets:
- Arn: !GetAtt 'ApiDestination.Arn'
Id: marbot
RoleArn: !GetAtt 'ApiRole.Arn'
Input: !Sub |
{
"Type": "monitoring-jump-start-connection",
"StackTemplate": "marbot-elastic-beanstalk",
"StackVersion": "1.5.0",
"Partition": "${AWS::Partition}",
"AccountId": "${AWS::AccountId}",
"Region": "${AWS::Region}",
"StackId": "${AWS::StackId}",
"StackName": "${AWS::StackName}"
}
##########################################################################
# #
# EVENTS #
# #
##########################################################################
ElasticBeanstalkEvent:
Type: 'AWS::Events::Rule'
Properties:
Description: 'Monitoring Elastic Beanstalk. (created by marbot)'
State: ENABLED
EventPattern:
source:
- 'aws.elasticbeanstalk'
detail-type:
- !If [ElasticBeanstalkResourceStatusChangeEnabled, 'Elastic Beanstalk resource status change', !Ref 'AWS::NoValue']
- !If [OtherResourceStatusChangeEnabled, 'Other resource status change', !Ref 'AWS::NoValue']
- !If [HealthStatusChangeEnabled, 'Health status change', !Ref 'AWS::NoValue']
- !If [ManagedUpdateStatusChangeEnabled, 'Managed update status change', !Ref 'AWS::NoValue']
detail:
Severity:
- !If [InfoSeverityEnabled, 'INFO', !Ref 'AWS::NoValue']
- !If [WarnSeverityEnabled, 'WARN', !Ref 'AWS::NoValue']
- !If [ErrorSeverityEnabled, 'ERROR', !Ref 'AWS::NoValue']
ApplicationName: !If [ApplicationNamesAll, !Ref 'AWS::NoValue', !Ref ApplicationNames]
EnvironmentName: !If [EnvironmentNamesAll, !Ref 'AWS::NoValue', !Ref EnvironmentNames]
Targets:
- Arn: !GetAtt 'ApiDestination.Arn'
Id: marbot
RoleArn: !GetAtt 'ApiRole.Arn'
Outputs:
StackName:
Description: 'Stack name.'
Value: !Sub '${AWS::StackName}'
StackTemplate:
Description: 'Stack template.'
Value: 'marbot-elastic-beanstalk'
StackVersion:
Description: 'Stack version.'
Value: '1.5.0'