Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWSTemplateFormatVersion: "2010-09-09"
Resources:
# Define VPC and Subnet
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
Tags:
- Key: Name
Value: techempower-vpc
Subnet:
Type: AWS::EC2::Subnet
Properties:
CidrBlock: 10.0.0.0/16
VpcId: !Ref VPC
Tags:
- Key: Name
Value: techempower-subnet
# Define Internet Gateway and the attachment to VPC
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: techempower-internet-gateway
VPCGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
# Define Route Table, its Route, and associate the Route Table with the Subnet
RouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: techempower-route-table
RouteInternetGateway:
Type: AWS::EC2::Route
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
RouteTableId: !Ref RouteTable
SubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref RouteTable
SubnetId: !Ref Subnet
# Define Security Group and its inbound rules (= ingress).
# The outbound (egress) rules are automatically set as "Allow All".
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupName: techempower-security-group
GroupDescription: security group allowing SSH and ICMP
VpcId: !Ref VPC
SecurityGropuIngressInternal:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: !Ref SecurityGroup
IpProtocol: -1
SourceSecurityGroupId: !Ref SecurityGroup
SecurityGropuIngressSSH:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: !Ref SecurityGroup
IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 219.100.133.243/32
SecurityGropuIngressICMP:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: !Ref SecurityGroup
IpProtocol: icmp
FromPort: 8
ToPort: 8
CidrIp: 219.100.133.243/32
# Define EC2 instance for WRK and its associated volumes
EC2InstanceWrk:
Type: AWS::EC2::Instance
Properties:
ImageId: "ami-0d7ed3ddb85b521a6"
InstanceType: m5.xlarge
KeyName: "performance-test-key-pair"
UserData:
Fn::Base64: |
#!/bin/bash
yum update -y
amazon-linux-extras install docker
# https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
# // but use unix:// instead of fd://
# https://forums.docker.com/t/failed-to-load-listeners-no-sockets-found-via-socket-activation-make-sure-the-service-was-started-by-systemd/62505
mkdir /etc/systemd/system/docker.service.d
echo "# /etc/systemd/system/docker.service.d/override.conf" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "[Service]" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart= " >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375" >> /etc/systemd/system/docker.service.d/startup_options.conf
service docker start
usermod -a -G docker ec2-user
NetworkInterfaces:
- AssociatePublicIpAddress: "true"
DeviceIndex: "0"
GroupSet:
- !Ref SecurityGroup
SubnetId: !Ref Subnet
# Volume of 20GB is allocated as TechEmpower docker containers have serveral hundred MBs in sizes
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
VolumeSize: 20
VolumeType: gp2
Tags:
- Key: Name
Value: tfb-client
# Define EC2 instance for Web Server and its associated volumes
EC2InstanceWebServer:
Type: AWS::EC2::Instance
Properties:
ImageId: "ami-0d7ed3ddb85b521a6"
InstanceType: m5.xlarge
KeyName: "performance-test-key-pair"
UserData:
Fn::Base64: |
#!/bin/bash
yum update -y
amazon-linux-extras install docker
# https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
# // but use unix:// instead of fd://
# https://forums.docker.com/t/failed-to-load-listeners-no-sockets-found-via-socket-activation-make-sure-the-service-was-started-by-systemd/62505
mkdir /etc/systemd/system/docker.service.d
echo "# /etc/systemd/system/docker.service.d/override.conf" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "[Service]" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart= " >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375" >> /etc/systemd/system/docker.service.d/startup_options.conf
service docker start
usermod -a -G docker ec2-user
NetworkInterfaces:
- AssociatePublicIpAddress: "true"
DeviceIndex: "0"
GroupSet:
- !Ref SecurityGroup
SubnetId: !Ref Subnet
# Volume of 20GB is allocated as TechEmpower docker containers have serveral hundred MBs in sizes
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
VolumeSize: 20
VolumeType: gp2
Tags:
- Key: Name
Value: tfb-server
# Define EC2 instance for DB and its associated volumes
EC2InstanceDB:
Type: AWS::EC2::Instance
Properties:
ImageId: "ami-0d7ed3ddb85b521a6"
InstanceType: m5.xlarge
KeyName: "performance-test-key-pair"
UserData:
Fn::Base64: |
#!/bin/bash
yum update -y
amazon-linux-extras install docker
# https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
# // but use unix:// instead of fd://
# https://forums.docker.com/t/failed-to-load-listeners-no-sockets-found-via-socket-activation-make-sure-the-service-was-started-by-systemd/62505
mkdir /etc/systemd/system/docker.service.d
echo "# /etc/systemd/system/docker.service.d/override.conf" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "[Service]" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart= " >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375" >> /etc/systemd/system/docker.service.d/startup_options.conf
service docker start
usermod -a -G docker ec2-user
NetworkInterfaces:
- AssociatePublicIpAddress: "true"
DeviceIndex: "0"
GroupSet:
- !Ref SecurityGroup
SubnetId: !Ref Subnet
# Volume of 20GB is allocated as TechEmpower docker containers have serveral hundred MBs in sizes
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
VolumeSize: 20
VolumeType: gp2
Tags:
- Key: Name
Value: tfb-database
# Define EC2 instance for Controller and its associated volumes
EC2InstanceController:
Type: AWS::EC2::Instance
Properties:
ImageId: "ami-0d7ed3ddb85b521a6"
InstanceType: t2.micro
KeyName: "performance-test-key-pair"
UserData:
Fn::Base64: |
#!/bin/bash
yum update -y
amazon-linux-extras install docker
# https://success.docker.com/article/how-do-i-enable-the-remote-api-for-dockerd
# // but use unix:// instead of fd://
# https://forums.docker.com/t/failed-to-load-listeners-no-sockets-found-via-socket-activation-make-sure-the-service-was-started-by-systemd/62505
mkdir /etc/systemd/system/docker.service.d
echo "# /etc/systemd/system/docker.service.d/override.conf" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "[Service]" >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart= " >> /etc/systemd/system/docker.service.d/startup_options.conf
echo "ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375" >> /etc/systemd/system/docker.service.d/startup_options.conf
service docker start
usermod -a -G docker ec2-user
# Controller needs to run the TechEmpower benchmark
yum -y install git
cd /home/ec2-user
git clone https://github.com/TechEmpower/FrameworkBenchmarks.git
NetworkInterfaces:
- AssociatePublicIpAddress: "true"
DeviceIndex: "0"
GroupSet:
- !Ref SecurityGroup
SubnetId: !Ref Subnet
Tags:
- Key: Name
Value: controller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment