forked from theburningmonk/lambda-logging-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
95 lines (89 loc) · 2.49 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
service: ${env:NAME}
plugins:
- serverless-pseudo-parameters
- serverless-iam-roles-per-function
provider:
name: aws
runtime: nodejs6.10
stage: dev
region: {env:REGION}
versionFunctions: true
functions:
ship-logs:
handler: functions/ship-logs/handler.handler
description: Sends CloudWatch logs to Logz.io
memorySize: 128
environment:
logstash_host: ${env:LOGSTASH_HOST}
logstash_port: ${env:LOGSTASH_PORT}
ssm_logz_io_token_key: ${env:SSM_LOGZ_IO_TOKEN_KEY}
iamRoleStatements:
- Effect: "Allow"
Action:
- "ssm:GetParameters"
- "ssm:GetParameter"
Resource: "arn:aws:ssm:#{AWS::Region}:#{AWS::AccountId}:parameter/*"
- Effect: "Allow"
Action:
- "kms:DescribeKey"
- "kms:Decrypt"
Resource: "*"
set-retention:
handler: functions/set-retention/handler.handler
description: Sets the log retention policy to the specified no. of days
memorySize: 128
environment:
retention_days: ${env:RETENTION_DAYS}
iamRoleStatements:
- Effect: "Allow"
Action:
- "logs:PutRetentionPolicy"
Resource: "*"
events:
- cloudwatchEvent:
event:
source:
- aws.logs
detail-type:
- AWS API Call via CloudTrail
detail:
eventSource:
- logs.amazonaws.com
eventName:
- CreateLogGroup
subscribe:
handler: functions/subscribe/handler.handler
description: Subscribe logs to the ship-logs function
memorySize: 128
environment:
dest_func: "${self:service}-${self:provider.stage}-ship-logs"
account_id: "#{AWS::AccountId}"
prefixes: ${env:CLOUDWATCH_LOGS_PREFIXES}
iamRoleStatements:
- Effect: "Allow"
Action:
- "logs:PutSubscriptionFilter"
Resource: "*"
events:
- cloudwatchEvent:
event:
source:
- aws.logs
detail-type:
- AWS API Call via CloudTrail
detail:
eventSource:
- logs.amazonaws.com
eventName:
- CreateLogGroup
resources:
Resources:
LambdaInvokePermission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName:
Fn::Join:
- ""
- - "Ref" : "ShipDashlogsLambdaFunction"
Principal: logs.#{AWS::Region}.amazonaws.com