forked from isucon/isucon11-qualify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf_pprotein.yaml
73 lines (68 loc) · 1.88 KB
/
cf_pprotein.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: isucon pprotein
Parameters:
VpcId:
Description: "AWS EC2 VPC ID"
Type: AWS::EC2::VPC::Id
SubnetId:
Description: "AWS EC2 Subnet ID"
Type: AWS::EC2::Subnet::Id
KeyPairName:
Description: "Amazon EC2 Key Pair"
Type: AWS::EC2::KeyPair::KeyName
GitHubUsername:
Description: "GitHub Username for SSH public key"
Type: String
Resources:
MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable SSH, HTTP, HTTPS access
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
- IpProtocol: -1
CidrIp: 192.168.0.0/16
- IpProtocol: tcp
FromPort: 9000
ToPort: 9000
CidrIp: 0.0.0.0/0
PproteinInstance:
Type: AWS::EC2::Instance
Properties:
InstanceType: c5.large
KeyName: !Ref KeyPairName
ImageId: ami-0796be4f4814fc3d5
SubnetId: !Ref SubnetId
PrivateIpAddress: '192.168.0.20'
SecurityGroupIds:
- !Ref MySecurityGroup
UserData:
Fn::Base64: !Sub |
#!/bin/bash
GITHUB_USER=${GitHubUsername}
mkdir -p /home/isucon/.ssh
curl -s https://github.com/$GITHUB_USER.keys >> /home/isucon/.ssh/authorized_keys
chown -R isucon:isucon /home/isucon/.ssh
chmod 600 /home/isucon/.ssh/authorized_keys
Tags:
- Key: Name
Value: pprotein
PproteinEIP:
Type: AWS::EC2::EIP
PproteinEIPAssociation:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: !Ref PproteinInstance
EIP: !Ref PproteinEIP