-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverless.yml
More file actions
95 lines (88 loc) · 2.49 KB
/
Copy pathserverless.yml
File metadata and controls
95 lines (88 loc) · 2.49 KB
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: lambda-duplicate-invocation-handler
Description: Identify and handle duplicate lambda invocations.
frameworkVersion: '>=1.64.0 <=1.74.0'
custom:
stage: ${opt:stage, self:provider.stage}
stackName: ${self:custom.stage}-${self:service.name}
provider:
name: aws
runtime: python3.7
stage: dev
region: us-east-1 # N. Virginia
logRetentionInDays: 7
stackTags:
APP: lambda-duplicate-invocation-handler
STAGE: ${self:custom.stage}
functions:
ExampleLambda:
name: ${self:custom.stackName}-ExampleLambda
description: Example lambda.
handler: src/lambda.handler
memorySize: 256
timeout: 10
role: ExampleLambdaRole
events:
- http:
path: /
method: post
environment:
EVENTS_TABLE: !Ref EventsTable
package:
exclude:
- node_modules/**
- package.json
- package-lock.json
- test/**
- README.md
resources:
Resources:
EventsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.stackName}-Events
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: LambdaName#EventID
AttributeType: S
KeySchema:
- AttributeName: LambdaName#EventID
KeyType: HASH
TimeToLiveSpecification:
AttributeName: 'Expires'
Enabled: true
ExampleLambdaRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Version: '2012-10-17'
Path: /
Policies:
- PolicyDocument:
Statement:
- Action:
- dynamodb:PutItem
- dynamodb:GetItem
Effect: Allow
Resource:
- Fn::GetAtt: [EventsTable, Arn]
- Action:
- logs:CreateLogStream
- logs:PutLogEvents
- logs:CreateLogGroup
Effect: Allow
Resource:
- 'Fn::Join':
- ':'
-
- 'arn:aws:logs'
- Ref: 'AWS::Region'
- Ref: 'AWS::AccountId'
- 'log-group:/aws/lambda/${self:custom.stackName}-ExampleLambda:*'
Version: '2012-10-17'
PolicyName: ${self:custom.stackName}-ExampleLambda-GeneratedRoles
RoleName: ${self:custom.stackName}-ExampleLambda
Type: AWS::IAM::Role