-
Notifications
You must be signed in to change notification settings - Fork 8
/
serverless.yml
78 lines (73 loc) · 2.03 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
service: api-database
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs14.x
lambdaHashingVersion: 20201221
region: eu-west-1
environment:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1'
iam:
role:
statements:
- Effect: Allow
Action:
- ssm:GetParameter
Resource:
- !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/examples/infra/database/cluster/arn'
- !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/examples/infra/database/endpoint/hostname'
- !Sub 'arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/examples/infra/database/secret/arn'
- Effect: 'Allow'
Action:
- secretsmanager:GetSecretValue
Resource:
- ${ssm:/examples/infra/database/secret/arn}
- Effect: Allow
Action:
- rds-data:BatchExecuteStatement
- rds-data:BeginTransaction
- rds-data:CommitTransaction
- rds-data:ExecuteStatement
- rds-data:RollbackTransaction
Resource:
- ${ssm:/examples/infra/database/cluster/arn}
package:
individually: true
plugins:
- serverless-webpack
custom:
webpack:
webpackConfig: 'webpack.config.js'
packager: 'yarn'
includeModules:
forceInclude:
- pg
functions:
data-api:
handler: src/data-api/index.handler
timeout: 28
events:
- httpApi:
method: get
path: /data-api
postgres:
handler: src/postgres/index.handler
timeout: 28
vpc:
securityGroupIds:
- !Ref SecurityGroup
subnetIds:
- ${ssm:/examples/infra/vpc/private-subnet-0/id}
- ${ssm:/examples/infra/vpc/private-subnet-1/id}
events:
- httpApi:
method: get
path: /postgres
resources:
Resources:
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: example-lambda
GroupDescription: example-lambda
VpcId: ${ssm:/examples/infra/vpc/id}