Skip to content

Commit

Permalink
feat: 🎸 Qualify->Contest(一部)
Browse files Browse the repository at this point in the history
  • Loading branch information
hijiki51 committed Nov 24, 2024
1 parent a999dfd commit d6e717f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def show
when "test"
CloudFormation.test_template(team)
when "qualify"
CloudFormation.qualify_template(team)
CloudFormation.contest_template(team)
else
raise "Unexpected type: #{params[:type]}"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Api::Contestant::CloudFormationsController < Api::Contestant::ApplicationC
def show
raise ActiveRecord::RecordNotFound, "no cloudformation template for final" if Rails.application.config.x.contest.final

template = CloudFormation.qualify_template(current_team)
template = CloudFormation.contest_template(current_team)

render protobuf: Isuxportal::Proto::Services::Contestant::GetCloudFormationResponse.new(
template: template,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const ContestantContestantInstanceList: React.FC<Props> = ({ session, cli
<a
className={`button is-info ${template === "" ? "is-loading" : ""}`}
href={templateBase64}
download="qualify_cloudformation.yaml"
download="contest_cloudformation.yaml"
>
CloudFormation テンプレートをダウンロード
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AWSTemplateFormatVersion: 2010-09-09
Description: >-
AWS CloudFormation for ISUCON14 Qualify
AWS CloudFormation for ISUCON14
Resources:
GetAvailabilityZoneFunctionExecutionRole:
Type: AWS::IAM::Role
Expand Down Expand Up @@ -95,7 +95,7 @@ Resources:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: !Ref VPC
GroupDescription: Security Group for ISUCON14 Qualify
GroupDescription: Security Group for ISUCON14
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: "22"
Expand Down Expand Up @@ -143,7 +143,7 @@ Resources:
Roles:
- !Ref InstanceRole

QualifyInstance1:
Instance1:
Type: AWS::EC2::Instance
Properties:
ImageId: <%= ami_id %>
Expand All @@ -161,7 +161,7 @@ Resources:
VolumeType: gp3
Tags:
- Key: Name
Value: isucon14-qualify-1
Value: isucon14-1
UserData:
Fn::Base64: |
#cloud-config
Expand All @@ -173,12 +173,12 @@ Resources:
content: '<%= portal_credentials %>'
runcmd:
- 'curl --retry 5 --retry-connrefused --max-time 10 --connect-timeout 5 "https://<%= portal_host %>/api/ssh_public_keys?token=<%= token %>" | sudo -u isucon sh -c "umask 077; cat > /home/isucon/.ssh/authorized_keys"'
QualifyInstanceIP1:
InstanceIP1:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
InstanceId: !Ref QualifyInstance1
QualifyInstance2:
InstanceId: !Ref Instance1
Instance2:
Type: AWS::EC2::Instance
Properties:
ImageId: <%= ami_id %>
Expand All @@ -196,7 +196,7 @@ Resources:
VolumeType: gp3
Tags:
- Key: Name
Value: isucon14-qualify-2
Value: isucon14-2
UserData:
Fn::Base64: |
#cloud-config
Expand All @@ -208,12 +208,12 @@ Resources:
content: '<%= portal_credentials %>'
runcmd:
- 'curl --retry 5 --retry-connrefused --max-time 10 --connect-timeout 5 "https://<%= portal_host %>/api/ssh_public_keys?token=<%= token %>" | sudo -u isucon sh -c "umask 077; cat > /home/isucon/.ssh/authorized_keys"'
QualifyInstanceIP2:
InstanceIP2:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
InstanceId: !Ref QualifyInstance2
QualifyInstance3:
InstanceId: !Ref Instance2
Instance3:
Type: AWS::EC2::Instance
Properties:
ImageId: <%= ami_id %>
Expand All @@ -231,7 +231,7 @@ Resources:
VolumeType: gp3
Tags:
- Key: Name
Value: isucon14-qualify-3
Value: isucon14-3
UserData:
Fn::Base64: |
#cloud-config
Expand All @@ -243,8 +243,8 @@ Resources:
content: '<%= portal_credentials %>'
runcmd:
- 'curl --retry 5 --retry-connrefused --max-time 10 --connect-timeout 5 "https://<%= portal_host %>/api/ssh_public_keys?token=<%= token %>" | sudo -u isucon sh -c "umask 077; cat > /home/isucon/.ssh/authorized_keys"'
QualifyInstanceIP3:
InstanceIP3:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
InstanceId: !Ref QualifyInstance3
InstanceId: !Ref Instance3
6 changes: 3 additions & 3 deletions portal/app/models/cloud_formation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module CloudFormation
TEST_ERB = ERB.new(File.read(File.join(File.dirname(__FILE__), './cf_templates/test.yaml.erb')))
QUALIFY_ERB = ERB.new(File.read(File.join(File.dirname(__FILE__), './cf_templates/qualify.yaml.erb')))
CONTEST_ERB = ERB.new(File.read(File.join(File.dirname(__FILE__), './cf_templates/contest.yaml.erb')))

def self.template(erb, b)
erb.result(b)
Expand All @@ -30,7 +30,7 @@ def self.test_template(team)
end
end

def self.qualify_template(team)
def self.contest_template(team)
zone_id = team.availability_zone
token = create_token(
team,
Expand All @@ -41,7 +41,7 @@ def self.qualify_template(team)
ami_id = Rails.application.config.x.qualify_ami_id

unless zone_id.nil?
template(QUALIFY_ERB, binding)
template(CONTEST_ERB, binding)
else
raise "Availability Zone should be set to team"
end
Expand Down

0 comments on commit d6e717f

Please sign in to comment.