-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
81 lines (80 loc) · 3.01 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
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
Transform: 'AWS::Serverless-2016-10-31'
Resources:
postsFunction:
Type: 'AWS::Serverless::Function'
Properties:
Runtime: nodejs12.x
Handler: index.postsHandler
CodeUri: ./src
Events:
lambdaGetAllPosts:
Type: Api
Properties:
Path: /posts
Method: GET
lambdaGetPost:
Type: Api
Properties:
Path: /posts/{postid}
Method: GET
lambdaAddPost:
Type: Api
Properties:
Path: /posts
Method: POST
lambdaAddComment:
Type: Api
Properties:
Path: /posts/{postid}/comments
Method: POST
lambdaUpdatePost:
Type: Api
Properties:
Path: /posts/{postid}
Method: PUT
lambdaDeletePost:
Type: Api
Properties:
Path: /posts/{postid}
Method: DELETE
lambdaDeleteComment:
Type: Api
Properties:
Path: /posts/{postid}/comments/{commentid}
Method: DELETE
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'dynamodb:Scan'
- 'dynamodb:Query'
- 'dynamodb:DeleteItem'
- 'dynamodb:GetItem'
- 'dynamodb:PutItem'
- 'dynamodb:UpdateItem'
Resource:
'Fn::Join':
- ''
- - 'arn:aws:dynamodb:'
- Ref: 'AWS::Region'
- ':'
- Ref: 'AWS::AccountId'
- ':table/posts'
postsTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: posts
AttributeDefinitions:
- AttributeName: postid
AttributeType: S
KeySchema:
- AttributeName: postid
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Outputs:
PublicApi:
Description: "API Gateway endpoint URL for Prod stage for Posts handler function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/posts/"