-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.yaml
56 lines (52 loc) · 1.43 KB
/
template.yaml
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Example template for an HTTP API that creates, updates, and deletes items in DynamoDB
Globals:
Function:
Timeout: 10
Resources:
DDBHandlerFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: dynamo-handler/
Handler: app.handler
Runtime: nodejs12.x
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref ItemsTable
Events:
GetAllItems:
Type: HttpApi
Properties:
Path: /items
Method: GET
GetAnItem:
Type: HttpApi
Properties:
Path: /items/{id}
Method: GET
DeleteAnItem:
Type: HttpApi
Properties:
Path: /items/{id}
Method: DELETE
CreateOrUpdateItem:
Type: HttpApi
Properties:
Path: /items
Method: PUT
ItemsTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: id
Type: String
TableName: http-crud-items
Outputs:
ApiEndpoint:
Description: "The invoke URL for our HTTP API"
Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/items"
Function:
Description: "DynamoDB handler function ARN"
Value: !GetAtt DDBHandlerFunction.Arn