-
Notifications
You must be signed in to change notification settings - Fork 62
/
serverless.yml
120 lines (102 loc) · 2.89 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
service: serverless-boilerplate
provider:
name: aws
runtime: nodejs12.x
stage: ${opt:stage, 'prod'}
region: us-east-1
timeout: 10 #Default Lambda timeout
memorySize: 512 #Default Lambda Memory Size
versionFunctions: false # No functions versioning
#role: arn:aws:iam::#{AWS::AccountId}:role/existing-role
package:
excludeDevDependencies: true
exclude:
- .git/**
- .vscode/**
- .test/**
environment: #Global Environment variables
${file(./configs/${self:provider.stage}.yml)}
iamRoleStatements: # Permissions for all of your functions can be set here
- Effect: Allow
Action: # Gives permission to DynamoDB tables in a specific region
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:*:*:*"
- Effect: Allow
Action: # Gives permission to Lambda execution
- lambda:InvokeFunction
- lambda:InvokeAsync
Resource: "*"
- Effect: Allow
Action: # Gives permission to SQS
- sqs:DeleteMessage
- sqs:ReceiveMessage
- sqs:SendMessage
Resource: arn:aws:sqs:*:*:*
custom:
region: ${self:provider.region}
stage: ${opt:stage, self:provider.stage}
prefix: ${self:custom.stage}-${self:service}
process: ${self:custom.prefix}-process
config: ${self:custom.prefix}-config
dynamo-books: ${self:custom.prefix}-BooksCatalog
sns-logs: ${self:custom.prefix}-trigger-logs
sqs-logs: ${self:custom.prefix}-messages-logs
serverless-offline:
host: '0.0.0.0'
splitStacks:
perFunction: true
perType: true
serverless-offline-sqs-esmq:
apiVersion: '2012-11-05'
endpoint: http://sqs:9324
region: sa-east-1
accessKeyId: root
secretAccessKey: root
dynamodb:
stages:
- local
- test
- dev
start:
host: "dynamo"
port: 8000
inMemory: false
migrate: true
noStart: true
plugins:
- serverless-pseudo-parameters
- serverless-dynamodb-local
- serverless-offline-scheduler
- serverless-offline-sqs-esmq
- serverless-offline
functions: ${file(serverless-dynamic.js)}
# Infrastrucure - Cloud Formation
resources: # CloudFormation template syntax
Resources:
#DynamoDB Books Table
BooksCatalog:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.dynamo-books}
AttributeDefinitions:
- AttributeName: hashkey
AttributeType: S
KeySchema:
- AttributeName: hashkey
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 1
# SQS Queue to Update DynamoDB
BooksQueueExample:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.sqs-logs}
MessageRetentionPeriod: 1209600
VisibilityTimeout: 60