-
Notifications
You must be signed in to change notification settings - Fork 7
/
serverless.yml
123 lines (106 loc) · 2.63 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
service: serverless-go
# frameworkVersion: '>=1.28.0 <2.0.0'
provider:
name: aws
runtime: go1.x
stage: ${opt:stage, 'dev'}
timeout: 10
memorySize: 256
versionFunctions: false
tags:
GLOBAL-TAG1: foo
GLOBAL-TAG2: bar
# Permissions for all of your functions can be set here
iamRoleStatements:
# Gives permission to DynamoDB tables in a specific region
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:*:*:*"
# Gives permission to SQS
- Effect: Allow
Action:
- sqs:GetQueueUrl
- sqs:DeleteMessage
- sqs:ReceiveMessage
- sqs:SendMessage
Resource: arn:aws:sqs:*:*:*
environment:
${file(./configs/${self:provider.stage}.yml)}
custom:
stage: ${opt:stage, self:provider.stage}
prefix: ${self:custom.stage}-${self:service}
dynamo-books-name: ${self:custom.prefix}-books-catalog
sqs-books-name: ${self:custom.prefix}-processing-queue
functions:
create:
handler: bin/books/endpoints/create
events:
- http:
path: books
method: post
tags:
TAGFUNCTION: Tag Value
read:
handler: bin/books/endpoints/read
events:
- http:
path: books
method: get
read_detail:
handler: bin/books/endpoints/detail
events:
- http:
path: books/{hashkey}
method: get
update:
handler: bin/books/endpoints/update
events:
- http:
path: books/{hashkey}
method: put
delete:
handler: bin/books/endpoints/delete
events:
- http:
path: books/{hashkey}
method: delete
worker:
handler: bin/books/functions/worker
events:
- sqs:
arn:
Fn::GetAtt:
- BooksQueueExample
- Arn
batchSize: 10
# CloudFormation template syntax
resources:
Resources:
#DynamoDB Books Table
BooksCatalog:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.dynamo-books-name}
AttributeDefinitions:
- AttributeName: hashkey
AttributeType: S
KeySchema:
- AttributeName: hashkey
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 10
WriteCapacityUnits: 10
# SQS Queue to Update DynamoDB
BooksQueueExample:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:custom.sqs-books-name}
MessageRetentionPeriod: 1209600
VisibilityTimeout: 120