-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
109 lines (109 loc) · 3.37 KB
/
serverless.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
service: alert-lambda
frameworkVersion: '3'
provider:
name: aws
runtime: python3.9
lambdaHashingVersion: 20201221
stage: ${opt:stage, 'dev'}
region: ${opt:region, "ap-northeast-1"}
memorySize: 256
iam:
role:
statements:
- Effect: 'Allow'
Action:
- 'ssm:GetParameter'
- 'sts:AssumeRole'
- 'logs:DescribeLogGroups'
- 'cloudwatch:DescribeAlarms'
- 'cloudwatch:PutMetricAlarm'
- 'cloudwatch:DeleteAlarms'
- 'lambda:ListFunctions'
Resource:
- '*'
environment: ${self:custom.environment}
functions:
add:
handler: src/handlers/add.handler
timeout: 300
delete:
handler: src/handlers/delete.handler
timeout: 300
create_error:
handler: src/handlers/create_error.handler
timeout: 60
plugins:
- serverless-step-functions
- serverless-python-requirements
- serverless-prune-plugin
stepFunctions: ${file(includes/state-machines.yml)}
custom:
pythonRequirements:
usePipenv: true
prune:
automatic: true
number: 3
environment:
STAGE: ${self:provider.stage}
SLACK_CHANNEL_ID: ${ssm(${self:provider.region}):/${self:service}/${self:provider.stage}/SLACK_CHANNEL_ID}
SLACK_WORKSPACE_ID: ${ssm(${self:provider.region}):/${self:service}/${self:provider.stage}/SLACK_WORKSPACE_ID}
SNS_TOPIC_ARN:
Ref: AlertLambdaTopic
package:
patterns:
- '!./**'
- ./src/**/*.py
resources:
Conditions:
CreateTokyoResources:
Fn::Equals:
- !Ref AWS::Region
- ap-northeast-1
Resources:
AlertLambdaTopic:
Type: "AWS::SNS::Topic"
Properties:
DisplayName: "AlertLambda-${self:provider.stage}-${self:provider.region}"
TopicName: "AlertLambdaTopic-${self:provider.stage}-${self:provider.region}"
AlertLambdaChatbotRole:
Type: "AWS::IAM::Role"
Condition: CreateTokyoResources
Properties:
RoleName: "AlertLambdaChatbotRole-${self:provider.stage}"
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: chatbot.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: "AlertLambdaChatbotPolicy-${self:provider.stage}"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- cloudwatch:Describe*
- cloudwatch:Get*
- cloudwatch:List*
- logs:Describe*
- logs:Get*
- logs:List*
- logs:StartQuery
- logs:StopQuery
- logs:TestMetricFilter
- logs:FilterLogEvents
Resource:
- "*"
AlertLambdaChatbot:
Type: "AWS::Chatbot::SlackChannelConfiguration"
Condition: CreateTokyoResources
Properties:
ConfigurationName: "AlertLambdaChatbot-${self:provider.stage}"
GuardrailPolicies:
- "arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess"
IamRoleArn: !GetAtt AlertLambdaChatbotRole.Arn
LoggingLevel: INFO
SlackChannelId: "${self:custom.environment.SLACK_CHANNEL_ID}"
SlackWorkspaceId: "${self:custom.environment.SLACK_WORKSPACE_ID}"