-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
132 lines (122 loc) · 3.51 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
service: tweet-m1-money-supply
description: Serverless project for Twitter bot that tweets the M1 money supply.
frameworkVersion: ">=2.1.0"
plugins:
- serverless-plugin-aws-alerts
- serverless-prune-plugin
- serverless-pseudo-parameters
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'stg'}
region: ${opt:region, 'us-west-1'}
profile: ${self:provider.stage}
deploymentBucket:
name: ${self:custom.environment.NAMESPACE_PREFIX}-${self:provider.stage}-${self:provider.region}-${self:service}
blockPublicAccess: true
maxPreviousDeploymentArtifacts: ${self:custom.environment.NUMBER_OF_PREVIOUS_DEPLOYMENT_ARTIFACTS_TO_RETAIN}
stackName: ${self:custom.environment.NAMESPACE_PREFIX}-${self:provider.stage}-${self:service}
stackPolicy:
- Effect: Allow
Principal: "*"
Resource: "*"
Action: "Update:*"
# - Effect: Deny
# Principal: "*"
# Resource: "*"
# Action:
# - Update:Replace
# - Update:Delete
# Condition:
# StringEquals:
# ResourceType:
# - AWS::SecretsManager::Secret
# - AWS::SNS::Topic
individually: true
iamRoleStatements:
# SecretsManager permissions.
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
Resource:
- Ref: SecretTwitterCredentials
package:
individually: true
exclude:
- ./*.json
- ./*.lock
- ./*.md
- ./*.yml
- .git/**
- functions/**
- layers/**
- node_modules/**
include:
- package.json
custom:
environment: ${file(./environment.yml):${self:provider.stage}}
namespace: m1
# serverless-prune-plugin config.
prune:
automatic: true
number: ${self:custom.environment.NUMBER_OF_LAMBDA_VERSIONS_TO_RETAIN}
# serverless-plugin-aws-alerts config.
alerts:
stages:
- stg
- prd
topics:
alarm:
topic: arn:aws:sns:${self:provider.region}:#{AWS::AccountId}:${self:provider.stage}-${self:service}-alarms
definitions:
functionInvocations:
namespace: "AWS/Lambda"
metric: Invocations
threshold: 10
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanOrEqualToThreshold
treatMissingData: missing
functionErrors:
namespace: "AWS/Lambda"
metric: Errors
threshold: 1
statistic: Maximum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanOrEqualToThreshold
treatMissingData: missing
functionDuration:
namespace: "AWS/Lambda"
metric: Duration
threshold: 5000
statistic: Maximum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanOrEqualToThreshold
treatMissingData: missing
functionThrottles:
namespace: "AWS/Lambda"
metric: Throttles
threshold: 1
statistic: Sum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanOrEqualToThreshold
treatMissingData: missing
functionAllFailures:
metric: AllFailures
threshold: 1
statistic: Maximum
period: 60
evaluationPeriods: 1
comparisonOperator: GreaterThanOrEqualToThreshold
pattern: "?unhandled ?Unhandled ?unexpected ?Unexpected ?Exception ?exception ?Error ?error ?Fail ?fail"
alarms:
- functionErrors
- functionAllFailures
functions: ${file(./functions.yml)}
resources:
- ${file(./resources-secrets.yml)}
- ${file(./resources-sns.yml)}