Skip to content

Instantly share code, notes, and snippets.

@ruslander
Created March 27, 2019 03:38
Show Gist options
  • Save ruslander/278776eac9544c6b272bce475a88f015 to your computer and use it in GitHub Desktop.
Save ruslander/278776eac9544c6b272bce475a88f015 to your computer and use it in GitHub Desktop.
pulumi - perf - topology
"use strict";
const aws = require("@pulumi/aws");
let size = "t1.micro";
let ami = "ami-0ac019f4fcb7cb7e6";
let localKey = "local-mac";
let nodes = [];
let vpc = new aws.ec2.Vpc("perf-vpc", {
cidrBlock: "10.1.0.0/16",
enableDnsHostnames: true,
enableDnsSupport: true
});
let publicSubnet = new aws.ec2.Subnet("perf-public-subnet", {
cidrBlock: "10.1.0.0/24",
vpcId: vpc.id,
})
let group = new aws.ec2.SecurityGroup("perf-sg", {
ingress: [
{ protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
{ protocol: "tcp", fromPort: 1990, toPort: 1990, cidrBlocks: ["0.0.0.0/0"] },
{ protocol: "tcp", fromPort: 2000, toPort: 2000, cidrBlocks: ["0.0.0.0/0"] },
],
egress: [
{ protocol: "-1", fromPort: 0, toPort: 0, cidrBlocks: ["0.0.0.0/0"] },
],
vpcId: vpc.id,
});
let igw = new aws.ec2.InternetGateway("perf-igw", {
vpcId: vpc.id,
});
let routeTable = new aws.ec2.RouteTable("perf-vpc-router", {
routes: [
{
cidrBlock: "0.0.0.0/0",
gatewayId: igw.id,
}
],
vpcId: vpc.id,
});
let routeTableAssociation = new aws.ec2.RouteTableAssociation("perf-add-subnet", {
routeTableId: routeTable.id,
subnetId: publicSubnet.id,
});
nodes.push(newInstance(group.id,"cl-node0"));
nodes.push(newInstance(group.id,"cl-node1"));
nodes.push(newInstance(group.id,"cl-node2"));
nodes.push(newInstance(group.id,"cl-bench"));
function newInstance(groupId, name) {
let userData =
`#!/bin/bash
sudo apt-get update -qq && apt-get install -y fio sysstat
sudo apt-get install -y iperf3 iftop
sudo apt install -y openjdk-8-jre-headless
`;
let clNode0 = new aws.ec2.Instance(name, {
tags: { "Name": name },
instanceType: size,
keyName: localKey,
securityGroups: [ group.id ],
ami: ami,
userData: userData,
subnetId: publicSubnet.id
});
let eip = new aws.ec2.Eip(name + "-ip", {
instance: clNode0.id,
vpc: true,
});
return eip;
}
exports.publicHostnames = nodes.map(s => s.publicIp);
@ruslander
Copy link
Author

Case1_Diagram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment