-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathalert.yml
67 lines (64 loc) · 1.74 KB
/
alert.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
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Stack for alerts via SNS.
Parameters:
Email:
Description: Email address that will receive alerts.
Type: String
Default: ''
Conditions:
HasEmail: !Not [!Equals [!Ref Email, '']]
Resources:
Topic:
Type: AWS::SNS::Topic
Properties: {}
TopicPolicy:
Type: AWS::SNS::TopicPolicy
Properties:
PolicyDocument:
Id: id1
Version: 2012-10-17
Statement:
- Sid: sid1
Effect: Allow
Principal:
Service:
- 'events.amazonaws.com' # Allow CloudWatch Events
- 'budgets.amazonaws.com' # Allow Budget Notifications
Action: 'sns:Publish'
Resource: !Ref Topic
- Sid: sid2
Effect: Allow
Principal:
# Allow CloudWatch Alarms, ElastiCache Notifications,
# Elastic Beanstalk Notifications, Auto Scaling Notification
AWS: '*'
Action: 'sns:Publish'
Resource: !Ref Topic
Condition:
StringEquals:
'AWS:SourceOwner': !Ref 'AWS::AccountId'
- Sid: Sid3
Effect: Allow
Principal:
Service: 'ses.amazonaws.com' # Allow SES Notifications & Events
Action: 'sns:Publish'
Resource: !Ref Topic
Condition:
StringEquals:
'AWS:Referer': !Ref 'AWS::AccountId'
Topics:
- !Ref Topic
EmailSubscription:
Condition: HasEmail
Type: AWS::SNS::Subscription
Properties:
Endpoint: !Ref Email
Protocol: email
TopicArn: !Ref Topic
Outputs:
TopicArn:
Description: The ARN of the alert topic.
Value: !Ref Topic
Export:
Name: !Sub '${AWS::StackName}-TopicArn'