-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
131 lines (124 loc) · 3.29 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
service: ${env:SERVICE_NAME}
provider:
name: aws
runtime: nodejs10.x
region: us-east-1
stage: ${env:VERSION}
deploymentBucket: ${env:DEPLOYMENT_BUCKET}
tracing: true
apiGateway:
restApiId:
'Fn::ImportValue': ${env:API_NAME}-${self:provider.stage}-restApiId
restApiRootResourceId:
'Fn::ImportValue': ${env:API_NAME}-${self:provider.stage}-rootResourceId
iamRoleStatements:
- Effect: Allow
Action:
- cloudwatch:*
- logs:*
- xray:*
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- sqs:*
- s3:*
Resource: "*"
vpc:
securityGroupIds:
- ${env:VPC_SECURITY_GROUP}
subnetIds:
- ${env:VPC_SUBNET_NAT_1}
- ${env:VPC_SUBNET_NAT_2}
- ${env:VPC_SUBNET_NAT_3}
environment:
NODE_ENV: ${env:NODE_ENV}
LOG_INFO_ENABLE: ${env:LOG_INFO_ENABLE}
LOG_ERROR_ENABLE: ${env:LOG_ERROR_ENABLE}
LOG_WARN_ENABLE: ${env:LOG_WARN_ENABLE}
plugins:
- serverless-offline
- serverless-plugin-tracing
- serverless-prune-plugin
custom:
serverless-offline:
apiKey: local
port: 3000
prune:
automatic: true
number: 3
functions:
sample:
name: name-sample
handler: src/controllers/_handler.debug
description: Description
timeout: 30
memorySize: 256
events:
- http:
path: /
method: GET
cors: true
private: true
authorizer:
type: CUSTOM
authorizerId:
'Fn::ImportValue': ${env:API_NAME}-${env:VERSION}-authorizerId
resources:
Resources:
## add a sqs queue dead
MessagesDeadLetterQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: queue-name-dead
MessageRetentionPeriod: 1209600
## add a sqs queue
Messages:
Type: AWS::SQS::Queue
Properties:
QueueName: queue-name
MessageRetentionPeriod: 1209600
VisibilityTimeout: 60
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- MessagesDeadLetterQueue
- Arn
maxReceiveCount: 10
DependsOn: "MessagesDeadLetterQueue"
# add table on dynamo
DynamoDbTableUserError:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
TableName: table-name
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: createdAt
AttributeType: N
- AttributeName: test
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: createdAt
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
GlobalSecondaryIndexes:
- IndexName: search-id-test
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: test
KeyType: RANGE
Projection:
NonKeyAttributes: []
ProjectionType: ALL
ProvisionedThroughput:
ReadCapacityUnits: '1'
WriteCapacityUnits: '1'