-
Notifications
You must be signed in to change notification settings - Fork 0
/
jeopardy.yml
181 lines (180 loc) · 5.1 KB
/
jeopardy.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
177
178
179
180
181
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Deploy Jeopardy server (using https://github.com/theGrue/jeopardy)'
Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance
Type: AWS::EC2::KeyPair::KeyName
ConstraintDescription: must be the name of an existing EC2 KeyPair.
InstanceType:
Description: Jeopardy Server EC2 instance type
Type: String
Default: t2.micro
AllowedValues:
- t2.micro
- t2.medium
- t3a.medium
ConstraintDescription: must be a valid EC2 instance type.
ManagementLocation:
Description: The IP address range that can be used to SSH manage the EC2 instances
Type: String
MinLength: '9'
MaxLength: '18'
Default: 0.0.0.0/0
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
GameServerLocation:
Description: The IP address range that can be used to connect to Jeopardy
Type: String
MinLength: '9'
MaxLength: '18'
Default: 0.0.0.0/0
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
Mappings:
AWSInstanceType2Arch:
t2.micro:
Arch: HVM64
t2.medium:
Arch: HVM64
t3a.medium:
Arch: HVM64
AWSInstanceType2NATArch:
t2.micro:
Arch: NATHVM64
t2.medium:
Arch: NATHVM64
t3a.medium:
Arch: NATHVM64
AWSRegionArch2AMI:
us-east-1:
HVM64: ami-07ebfd5b3428b6f4d
Resources:
JeopardyEC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType:
Ref: InstanceType
SecurityGroups:
- Ref: JeopardyInstanceSecurityGroup
KeyName:
Ref: KeyName
Tags:
-
Key: "Name"
Value: !Join
- ''
- - 'Jeopardy_'
- !Ref AWS::StackName
ImageId:
Fn::FindInMap:
- AWSRegionArch2AMI
- Ref: AWS::Region
- Fn::FindInMap:
- AWSInstanceType2Arch
- Ref: InstanceType
- Arch
UserData: !Base64
'Fn::Join':
- ''
- - |
#!/bin/bash -x
- |
# updates
- |
apt update
- |
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
- |
DEBIAN_FRONTEND=noninteractive apt install -y git curl screen python-pip
- |
pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz
- |
curl -fsSL https://get.docker.com | sh
- |
# config and run
- |
mkdir /opt/jeopardy
- |
cat << EOF > /opt/jeopardy/Dockerfile
- |
FROM ubuntu:latest
- |
WORKDIR /opt/jeopardy
- |
RUN apt -y update && apt -y upgrade
- |
RUN apt install -y git curl software-properties-common
- |
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
- |
RUN apt install -y nodejs
- |
RUN npm install -g bower
- |
RUN node --version
- |
RUN npm --version
- |
RUN bower --version
- |
RUN git clone https://github.com/theGrue/jeopardy .
- |
RUN npm install && bower install --allow-root
- |
EXPOSE 3000
- |
ENTRYPOINT node app.js
- |
EOF
- |
docker build --tag jeopardy:1.0 /opt/jeopardy
- |
docker run --name jeopardy -it -d -p 80:3000 jeopardy:1.0
- |+
- |
# Signal the status from cfn-init
- '/usr/local/bin/cfn-signal -e $? '
- ' --stack '
- !Ref 'AWS::StackName'
- ' --resource JeopardyEC2Instance '
- ' --region '
- !Ref 'AWS::Region'
- |+
CreationPolicy:
ResourceSignal:
Timeout: PT7M
JeopardyInstanceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable Access for Jeopardy Server
SecurityGroupIngress:
- IpProtocol: '-1'
CidrIp:
Ref: ManagementLocation
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp:
Ref: GameServerLocation
Outputs:
AlexView:
Description: Where the person playing "Alex" goes
Value: !Join
- ''
- - 'http://'
- Fn::GetAtt:
- JeopardyEC2Instance
- PublicDnsName
- '/'
BoardView:
Description: Where the players go
Value: !Join
- ''
- - 'http://'
- Fn::GetAtt:
- JeopardyEC2Instance
- PublicDnsName
- '/#/board'
BuzzerTool:
Description: Smartphone buzzer system
Value: 'https://buzzin.live/'