-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpokerdot-storage.template.yaml
114 lines (103 loc) · 2.96 KB
/
pokerdot-storage.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Persistent storage for Pokerdot application
Parameters:
Stage:
Type: String
Default: prod
Resources:
WebrootAccessIdentityID:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: Pokerdot webroot CDN access
# Bucket that will hold the public static assets.
# The application will be served out of this bucket using CloudFront
WebrootBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub "pokerdot-www-${Stage}-${AWS::AccountId}"
Tags:
- Key: "app"
Value: "pokerdot"
- Key: "stage"
Value: !Ref Stage
WebrootBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref WebrootBucket
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:GetObject
Resource: !Sub "arn:aws:s3:::${WebrootBucket}/*"
Principal:
AWS: !Sub "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${WebrootAccessIdentityID}"
GamesTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "pokerdot-games-${Stage}"
BillingMode: PAY_PER_REQUEST
SSESpecification:
SSEEnabled: True
TimeToLiveSpecification:
AttributeName: "expiry"
Enabled: true
AttributeDefinitions:
- AttributeName: "gameCode"
AttributeType: "S"
- AttributeName: "gameId"
AttributeType: "S"
KeySchema:
- AttributeName: "gameCode"
KeyType: "HASH"
- AttributeName: "gameId"
KeyType: "RANGE"
Tags:
- Key: "app"
Value: "pokerdot"
- Key: "stage"
Value: !Ref Stage
- Key: "table"
Value: "games"
PlayersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "pokerdot-players-${Stage}"
BillingMode: PAY_PER_REQUEST
SSESpecification:
SSEEnabled: True
TimeToLiveSpecification:
AttributeName: "expiry"
Enabled: true
AttributeDefinitions:
- AttributeName: "gameId"
AttributeType: "S"
- AttributeName: "playerId"
AttributeType: "S"
KeySchema:
- AttributeName: "gameId"
KeyType: "HASH"
- AttributeName: "playerId"
KeyType: "RANGE"
Tags:
- Key: "app"
Value: "pokerdot"
- Key: "stage"
Value: !Ref Stage
- Key: "table"
Value: "games"
Outputs:
WebrootAccessIdentityID:
Description: "Webroot access identity ID"
Value: !Ref WebrootAccessIdentityID
GamesTableName:
Description: "Games table name"
Value: !Ref GamesTable
PlayersTableName:
Description: "Players table name"
Value: !Ref PlayersTable
WebrootBucketName:
Description: "Webroot bucket's name"
Value: !Ref WebrootBucket