-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
executable file
·89 lines (82 loc) · 2.12 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
# Copyright (c) 2019 Matthew Rankin. All rights reserved.
# Project site: https://github.com/matthewrankin/serverless-go-crud
# Use of this source code is governed by a MIT-style license that
# can be found in the LICENSE file for the project.
service: serverless-go-crud
custom:
todosTableName: ${self:service}-${self:provider.stage}-todos
todosTableArn: # ARNs are addresses of deployed services in AWS space
Fn::Join:
- ":"
- - arn
- aws
- dynamodb
- Ref: AWS::Region
- Ref: AWS::AccountId
- table/${self:custom.todosTableName}
provider:
name: aws
runtime: go1.x
stage: dev
region: us-east-2
environment:
TODOS_TABLE_NAME: ${self:custom.todosTableName}
iamRoleStatements: # Defines what other AWS services our lambda function can access
- Effect: Allow # Allow access to DynamoDB tables
Action:
- 'dynamodb:Scan'
- 'dynamodb:GetItem'
- 'dynamodb:PutItem'
- 'dynamodb:UpdateItem'
- 'dynamodb:DeleteItem'
Resource:
- ${self:custom.todosTableArn}
package:
exclude:
- ./**
include:
- ./bin/**
functions:
addtodo:
handler: bin/addtodo
events:
- http:
path: todos
method: post
cors: true
listtodos:
handler: bin/listtodos
events:
- http:
path: todos
method: get
cors: true
completetodo:
handler: bin/completetodo
events:
- http:
path: todos/{id}
method: patch
cors: true
deletetodo:
handler: bin/deletetodo
events:
- http:
path: todos/{id}
method: delete
cors: true
resources:
Resources: # Support AWS services
TodosTable: # Define a new DynamoDB Table resource to store todo items
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.todosTableName}
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH