-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice.yml
97 lines (81 loc) · 2.23 KB
/
service.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
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: "[CloudFormation] [Utility] Posting CloudWatch Events to Slack."
Parameters:
Token:
Type: String
Description: |
The Slack App access token the bot will use to post messages.
Username:
Type: String
Description: |
The username of the bot inside Slack. Messages will be posted under this
username.
Icon:
Type: String
ConstraintDescription: |
Must be a slack compatible emoji, starting and ending with a colon.
Description: |
The Emoji Icon for the bot.
Globals:
Function:
Runtime: nodejs8.10
Timeout: 10
Resources:
EventTopic:
Type: AWS::SNS::Topic
EventFunction:
Type: AWS::Serverless::Function
Properties:
Handler: event.handler
CodeUri: ./out
Role: !GetAtt EventFunctionExecutionRole.Arn
Environment:
Variables:
BOT_TOKEN: !Ref Token
BOT_USERNAME: !Ref Username
BOT_ICON: !Ref Icon
EventFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub "/aws/lambda/${EventFunction}"
RetentionInDays: 3
EventFunctionExecutionRole:
Type: AWS::IAM::Role
Properties:
Path: "/"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service:
- !Sub "lambda.${AWS::URLSuffix}"
Action: sts:AssumeRole
EventFunctionExecutionPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyName: EventFunctionExecutionPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- !GetAtt EventFunctionLogGroup.Arn
Roles:
- !Ref EventFunctionExecutionRole
Outputs:
EventFunction:
Description: The name of the EventFunction to fire
Value: !Ref EventFunction
Export:
Name: EventFunction
EventFunctionArn:
Description: The ARN of the EventFunction
Value: !GetAtt EventFunction.Arn
Export:
Name: EventFunctionArn