-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
104 lines (92 loc) · 2.33 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
# For full config options, check the docs:
# docs.serverless.com
service: RustyPuppies
provider:
name: aws
runtime: rust
memorySize: 128
region: eu-north-1
stage: dev
environment:
RUST_BACKTRACE: 1
DYNAMODB_TABLE: PuppyTable-${opt:stage, self:provider.stage, 'dev'}
SQS_NAME: PuppyQueue-${opt:stage, self:provider.stage, 'dev'}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:GetItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:Scan*
Resource: arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/${self:provider.environment.DYNAMODB_TABLE}
- Effect: "Allow"
Action:
- "sqs:SendMessage"
- "sqs:GetQueueUrl"
Resource: "arn:aws:sqs:#{AWS::Region}:#{AWS::AccountId}:${self:provider.environment.SQS_NAME}"
- Effect: "Allow"
Action:
- "sqs:ListQueues"
Resource: "arn:aws:sqs:#{AWS::Region}:#{AWS::AccountId}:*"
package:
individually: true
plugins:
- serverless-pseudo-parameters
- serverless-rust
functions:
barker:
handler: puppy_barker
events:
- sqs:
arn:
Fn::GetAtt:
- PuppyQueue
- Arn
create:
handler: puppy_create
events:
- http:
path: /puppy
method: POST
request:
schema:
application/json: ${file(schema/puppy.json)}
read:
handler: puppy_read
events:
- http:
path: /puppy/{name}
method: GET
update:
handler: puppy_update
events:
- http:
path: /puppy/{name}
method: PUT
request:
schema:
application/json: ${file(schema/puppy_put.json)}
delete:
handler: puppy_delete
events:
- http:
path: /puppy/{name}
method: DELETE
resources:
Resources:
PuppyTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:provider.environment.DYNAMODB_TABLE}
AttributeDefinitions:
- AttributeName: name
AttributeType: S
KeySchema:
- AttributeName: name
KeyType: HASH
BillingMode: PAY_PER_REQUEST
PuppyQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: ${self:provider.environment.SQS_NAME}