-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
96 lines (90 loc) · 3.12 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
service: flappy-detector
frameworkVersion: '2'
provider:
name: aws
# Replace this role with your lambda specific role defined in Terraform
role:
Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/flappy_detector_lambda
region: ${opt:region, 'us-west-2'}
deploymentBucket: amplify-devops-${self:custom.regionShortName}-serverless-common
runtime: python3.8
memorySize: 512
environment:
# These fields allow you to set your log level to see unified service tagging on datadog
LOG_LEVEL: ${self:custom.config.log_level}
FLAPPY_DETECTOR_EC2_TABLE: ${self:custom.config.ec2_table}
FLAPPY_DETECTOR_ROLE: flappy_detector_assumed
FLAPPY_DETECTOR_MAX_EVENT_AGE_IN_MINS: ${self:custom.config.max_event_age_in_mins}
FLAPPY_DETECTOR_MIN_NUM_EVENTS: ${self:custom.config.min_num_events}
FLAPPY_DETECTOR_MIN_SPREAD: ${self:custom.config.min_spread}
timeout: 300
versionFunctions: false
logRetentionInDays: 7
stackTags:
environment: ${opt:stage}
application: ${self:service}
version: ${env:DD_VERSION, 'unknown'} # Set version tag so that Datadog tags metrics with the version that was deployed
lambda_nested_source: python # Set a extra tag so we can tell Datadog logs to parse logs using python pipeline
tracing:
apiGateway: true
lambda: true
endpointType: regional
httpApi:
payload: '2.0'
package:
include:
- dependencies/**
exclude:
- .coverage
- .git
- .gitignore
- flappy_detector/**/*.py[cod]
- ez_setup.py
- MANIFEST.in
- requirements.txt
- setup.cfg
- setup.py
- test-requirements.txt
- flappy_detector.egg-info/**
- docs/**
- reports/**
- test/**
- .tox/**
- node_modules/**
functions:
ingest:
handler: flappy_detector/handlers/ingest.handler
description: Ingests events for Flappy Detection
events:
- sns:
# Use our own account id because Fn::Sub doesn't appear to work here...
arn: arn:aws:sns:us-west-2:${self:custom.config.account_id}:ec2_state_change_uw2
- sns:
# Use our own account id because Fn::Sub doesn't appear to work here...
arn: arn:aws:sns:us-east-1:${self:custom.config.account_id}:ec2_state_change_ue1
detector:
handler: flappy_detector/handlers/detect.handler
description: Detects flappiness in ingested events
events:
- schedule: rate(30 minutes)
plugins:
- serverless-python-requirements
- serverless-plugin-datadog
custom:
# This tells serverless to use the current stage config as defined in config.yml
config: ${file(./config.yml):${opt:stage}}
# This forwards logs and metrics to the datadog-forwarder lambda which is deployed in every account and region
datadog:
forwarder:
Fn::Sub: arn:aws:lambda:${self:provider.region}:${AWS::AccountId}:function:datadog-forwarder
enableXrayTracing: true
regionShortName: ${file(./region_short_names.yml):${self:provider.region}}
pythonRequirements:
dockerizePip: "non-linux"
dockerRunCmdExtraArgs: ['-v', '${env:HOME}:/root']
fileName: requirements.txt
noDeploy:
- boto3
- botocore
useDownloadCache: true
useStaticCache: true