-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamodb-template.yaml
73 lines (71 loc) · 2.43 KB
/
dynamodb-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
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Cloudformation stack for the article "Using Amazon API Gateway
as proxy for DynamoDB" by Stefano Buliani on 26-02-2016'
Parameters:
ReadCapacityUnits:
Description: Provisioned read throughput
Type: Number
Default: '5'
MinValue: '5'
MaxValue: '10000'
ConstraintDescription: must be between 5 and 10000
WriteCapacityUnits:
Description: Provisioned write throughput
Type: Number
Default: '5'
MinValue: '5'
MaxValue: '10000'
ConstraintDescription: must be between 5 and 10000
Resources:
CommentsApi:
Type: AWS::ApiGateway::RestApi
Properties:
Name: CommentsApi
Comments:
Type: AWS::ApiGateway::Resources
Properties:
RestApiId: !Ref CommentsApi
ParentId: !GetAtt
- CommentsApi
PathPart: comments
PostComments:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref CommentsApi
ResourceId: !GetAtt
- CommentsApi
- Comments
HttpMethod: POST
AuthorizationType: NONE
Integration:
Type: AWS
Uri: arn:aws:dynamodb:eu-west-2:756525791342:table/dev-apigateway-proxy-dynamo-CommentsTable-C8UVLP5VJUPE
CommentsTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: commentId
AttributeType: S
- AttributeName: pageId
AttributeType: S
KeySchema:
- AttributeName: commentId
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: pageId-index
KeySchema:
- AttributeName: pageId
KeyType: "HASH"
Projection:
NonKeyAttributes: ['pageId', 'userName', 'message']
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: !Ref 'ReadCapacityUnits'
WriteCapacityUnits: !Ref 'WriteCapacityUnits'
ProvisionedThroughput:
ReadCapacityUnits: !Ref 'ReadCapacityUnits'
WriteCapacityUnits: !Ref 'WriteCapacityUnits'
Outputs:
TableName:
Value: !Ref 'CommentsTable'
Description: Comments DynamoDB table