-
Notifications
You must be signed in to change notification settings - Fork 7
/
single-api.yml
88 lines (81 loc) · 3.09 KB
/
single-api.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
service: abu-api
variablesResolutionMode: 20210219
package:
individually: true
excludeDevDependencies: true
plugins:
- serverless-bundle
- serverless-s3-local
- serverless-offline
custom:
BucketName: ${file(./config/${self:provider.stage}.yml):UPLOAD_BUCKET, 'local'}
BucketResizePrefix: ${file(./config/${self:provider.stage}.yml):UPLOAD_PREFIX, 'uploads'}
serverless-offline:
httpPort: 8061
lambdaPort: 8066
noPrependStageInUrl: true
useChildProcesses: true
s3:
port: 8064
directory: ./.s3-local
cors: ./packages/upload/s3-cors.xml
bundle:
packager: yarn
provider:
name: aws
runtime: nodejs14.x
memorySize: 512
stage: ${opt:stage, 'local'}
region: ${file(./config/${self:provider.stage}.yml):REGION, 'ap-southeast-1'}
profile: ${file(./config/${self:provider.stage}.yml):PROFILE, 'default'}
lambdaHashingVersion: 20201221
environment:
TZ: ${file(./config/${self:provider.stage}.yml):TZ, 'Asia/Manila'}
STAGE: ${self:provider.stage}
NODE_ENV: ${self:provider.stage}
DEBUG: ${file(./config/${self:provider.stage}.yml):DEBUG, 'lambda:event,lambda:error'}
COG_POOL_ID: ${file(./config/${self:provider.stage}.yml):COG_POOL_ID, 'pool-id'}
COG_ACCESS_KEY_ID: ${file(./config/${self:provider.stage}.yml):COG_ACCESS_KEY_ID, 'access-key-id'}
COG_SECRET_ACCESS_KEY: ${file(./config/${self:provider.stage}.yml):COG_SECRET_ACCESS_KEY, 'secret-key-id'}
DDB_REGION: ${file(./config/${self:provider.stage}.yml):REGION, 'ap-southeast-1'}
DDB_ENDPOINT: ${file(./config/${self:provider.stage}.yml):DDB_ENDPOINT, ''}
DDB_TABLE: ${file(./config/${self:provider.stage}.yml):DDB_TABLE, 'abu-local'}
S3_BUCKET: ${self:custom.BucketName}
S3_BUCKET_PREFIX: ${self:custom.BucketResizePrefix}
S3_BASE_URL: ${file(./config/${self:provider.stage}.yml):UPLOAD_BASE_URL, 'http://localhost:8064/local'}
PAGINATION_SECRET: ${file(./config/${self:provider.stage}.yml):PAGINATION_SECRET, 'some-random-key'}
iam:
role:
statements:
- Effect: Allow
Action:
- "s3:*"
Resource:
- "arn:aws:s3:::${self:custom.BucketName}"
- "arn:aws:s3:::${self:custom.BucketName}/*"
- Effect: Allow
Action:
- dynamodb:Scan
- dynamodb:Query
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.DDB_TABLE}"
- "arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.DDB_TABLE}/*"
functions: ${file(./functions.js)}
resources:
Resources:
ApiGatewayAuthorizer:
DependsOn:
- ApiGatewayRestApi
Type: AWS::ApiGateway::Authorizer
Properties:
Name: cognito-authorizer
IdentitySource: method.request.header.Authorization
RestApiId:
Ref: ApiGatewayRestApi
Type: COGNITO_USER_POOLS
ProviderARNs:
- ${file(./config/${self:provider.stage}.yml):COG_POOL_ARN, 'pool-arn'}