forked from aws-samples/eb-java-scorekeep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yml
176 lines (176 loc) · 5.82 KB
/
template.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
AWSTemplateFormatVersion: 2010-09-09
Description: An AWS Elastic application that uses DynamoDB.
Parameters:
emailAddress:
Type: String
Default: UPDATEME
Resources:
application:
Type: AWS::ElasticBeanstalk::Application
Properties:
ApplicationName: Scorekeep
Description: RESTful web API in Java with Spring that provides an HTTP interface for creating and managing game sessions and users.
version:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
ApplicationName: !Ref application
SourceBundle: ./package.zip
environment:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName: !Ref application
EnvironmentName: BETA
OptionSettings:
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: AWS_REGION
Value: !Ref AWS::Region
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: NOTIFICATION_TOPIC
Value: !Ref notificationTopic
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: NOTIFICATION_EMAIL
Value: !Ref emailAddress
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: USER_TABLE
Value: !Ref userTable
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: SESSION_TABLE
Value: !Ref sessionTable
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: GAME_TABLE
Value: !Ref gameTable
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: MOVE_TABLE
Value: !Ref moveTable
- Namespace: aws:elasticbeanstalk:application:environment
OptionName: STATE_TABLE
Value: !Ref stateTable
- Namespace: aws:autoscaling:launchconfiguration
OptionName: IamInstanceProfile
Value: !Ref instanceProfile
PlatformArn: arn:aws:elasticbeanstalk:::platform/Corretto 8 running on 64bit Amazon Linux 2
VersionLabel: !Ref version
instanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: /
Roles:
- !Ref role
role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
Policies:
- PolicyName: resources
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: ResourceAccess
Action:
- '*'
Effect: Allow
Resource:
- 'arn:aws:dynamodb:*:*:table/scorekeep-*'
- 'arn:aws:sns:*:*:scorekeep-*'
- PolicyName: beanstalk
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: BucketAccess
Action:
- 's3:Get*'
- 's3:List*'
- 's3:PutObject'
Effect: Allow
Resource: arn:aws:s3:::elasticbeanstalk*
- Sid: MetricsAccess
Action:
- 'cloudwatch:PutMetricData'
Effect: Allow
Resource: '*'
Path: /
notificationTopic:
Type: AWS::SNS::Topic
userTable:
Type: AWS::DynamoDB::Table
Properties:
KeySchema:
HashKeyElement: {AttributeName: id, AttributeType: S}
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
sessionTable:
Type: AWS::DynamoDB::Table
Properties:
KeySchema:
HashKeyElement: {AttributeName: id, AttributeType: S}
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
gameTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
- AttributeName: "session"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
GlobalSecondaryIndexes:
- IndexName: "session-index"
KeySchema:
- AttributeName: "session"
KeyType: "HASH"
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
Projection: { ProjectionType: ALL }
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
moveTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
- AttributeName: "game"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
GlobalSecondaryIndexes:
- IndexName: "game-index"
KeySchema:
- AttributeName: "game"
KeyType: "HASH"
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
Projection: { ProjectionType: ALL }
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
stateTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: "id"
AttributeType: "S"
- AttributeName: "game"
AttributeType: "S"
KeySchema:
- AttributeName: "id"
KeyType: "HASH"
GlobalSecondaryIndexes:
- IndexName: "game-index"
KeySchema:
- AttributeName: "game"
KeyType: "HASH"
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
Projection: { ProjectionType: ALL }
ProvisionedThroughput: {ReadCapacityUnits: 2, WriteCapacityUnits: 2}
Outputs:
endpoint:
Description: Website URL
Value: !GetAtt environment.EndpointURL
Export:
Name: !Join ["-", [!Ref "AWS::StackName","endpoint"]]