Skip to content

Instantly share code, notes, and snippets.

@miyamoto-daisuke
Created May 24, 2013 03:01
Show Gist options
  • Save miyamoto-daisuke/5641023 to your computer and use it in GitHub Desktop.
Save miyamoto-daisuke/5641023 to your computer and use it in GitHub Desktop.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Tungsten Replicator evaluation",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server",
"Type" : "String"
},
"SlaveMasterPassword" : {
"Description" : "Password of RDS master user",
"Default": "slavepass",
"Type" : "String"
}
},
"Mappings": {
"AmazonLinux": {
"us-east-1": { "64bit": "ami-3275ee5b", "32bit": "ami-5675ee3f" },
"us-west-2": { "64bit": "ami-ecbe2adc", "32bit": "ami-d0be2ae0" },
"us-west-1": { "64bit": "ami-66d1fc23", "32bit": "ami-d8d1fc9d" },
"eu-west-1": { "64bit": "ami-44939930", "32bit": "ami-6893991c" },
"ap-southeast-1": { "64bit": "ami-aa9ed2f8", "32bit": "ami-a29ed2f0" },
"ap-southeast-2": { "64bit": "ami-363eaf0c", "32bit": "ami-383eaf02" },
"ap-northeast-1": { "64bit": "ami-173fbf16", "32bit": "ami-0f3fbf0e" },
"sa-east-1": { "64bit": "ami-dd6bb0c0", "32bit": "ami-a56bb0b8" }
},
"AZ": {
"us-east-1": { "left": "us-east-1c", "right": "us-east-1e" },
"us-west-2": { "left": "us-west-2a", "right": "us-west-2b" },
"us-west-1": { "left": "us-west-1a", "right": "us-west-1b" },
"eu-west-1": { "left": "eu-west-1a", "right": "eu-west-1b" },
"ap-southeast-1": { "left": "ap-southeast-1a", "right": "ap-southeast-1b" },
"ap-southeast-2": { "left": "ap-southeast-2a", "right": "ap-southeast-2b" },
"ap-northeast-1": { "left": "ap-northeast-1a", "right": "ap-northeast-1c" },
"sa-east-1": { "left": "sa-east-1a", "right": "sa-east-1b" }
}
},
"Resources": {
"Vpc" : {
"Type" : "AWS::EC2::VPC",
"Properties" : {
"CidrBlock" : "10.0.0.0/16",
"InstanceTenancy" : "default"
}
},
"Igw" : {
"Type" : "AWS::EC2::InternetGateway"
},
"IgwAttachment" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"VpcId" : {"Ref": "Vpc"},
"InternetGatewayId" : {"Ref": "Igw"}
}
},
"SubnetA" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"AvailabilityZone" : { "Fn::FindInMap": [ "AZ", { "Ref": "AWS::Region" }, "right" ]},
"CidrBlock" : "10.0.0.0/24",
"VpcId" : {"Ref": "Vpc"}
}
},
"SubnetB" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"AvailabilityZone" : { "Fn::FindInMap": [ "AZ", { "Ref": "AWS::Region" }, "left" ]},
"CidrBlock" : "10.0.1.0/24",
"VpcId" : {"Ref": "Vpc"}
}
},
"Rtb" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : {"Ref": "Vpc"},
"Tags" : []
}
},
"RouteToIgw": {
"Type" : "AWS::EC2::Route",
"Properties" : {
"DestinationCidrBlock" : "0.0.0.0/0",
"RouteTableId" : {"Ref": "Rtb"},
"GatewayId" : {"Ref": "Igw"}
}
},
"Rtbassoc" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"RouteTableId" : {"Ref": "Rtb"},
"SubnetId" : {"Ref": "SubnetA"}
}
},
"SgSSH" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable SSH access via port 22",
"SecurityGroupIngress": [
{
"IpProtocol" : "tcp",
"CidrIp" : "0.0.0.0/0",
"FromPort" : "22",
"ToPort" : "22"
}
],
"VpcId" : {"Ref": "Vpc"}
}
},
"SgTungstenBridge" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable Tungsten access to master port 2112",
"VpcId" : {"Ref": "Vpc"}
}
},
"SgTungstenMaster" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable Tungsten access via port 2112",
"SecurityGroupIngress": [
{
"IpProtocol" : "tcp",
"SourceSecurityGroupId": { "Ref": "SgTungstenBridge" },
"FromPort" : "2112",
"ToPort" : "2112"
}
],
"VpcId" : {"Ref": "Vpc"}
}
},
"SgMySQL" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable MySQL access via port 3306",
"SecurityGroupIngress": [
{
"IpProtocol" : "tcp",
"CidrIp" : "0.0.0.0/0",
"FromPort" : "3306",
"ToPort" : "3306"
}
],
"VpcId" : {"Ref": "Vpc"}
}
},
"TungstenMasterInstance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Fn::FindInMap": [ "AmazonLinux", { "Ref": "AWS::Region" }, "64bit" ]},
"InstanceType" : "t1.micro",
"PrivateIpAddress" : "10.0.0.10",
"KeyName" : { "Ref" : "KeyName" },
"SecurityGroupIds" : [
{ "Ref" : "SgSSH" },
{ "Ref" : "SgTungstenMaster" },
{ "Ref" : "SgMySQL" }
],
"SubnetId" : {"Ref": "SubnetA"},
"Tags" : [{"Key": "Name", "Value": "tungsten-master"}],
"Monitoring" : "False",
"Tenancy" : "default"
}
},
"TungstenMasterEIP": {
"Type": "AWS::EC2::EIP",
"Properties": {
"InstanceId": { "Ref": "TungstenMasterInstance" },
"Domain" : "vpc"
}
},
"TungstenBridgeInstance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Fn::FindInMap": [ "AmazonLinux", { "Ref": "AWS::Region" }, "64bit" ]},
"InstanceType" : "t1.micro",
"PrivateIpAddress" : "10.0.0.20",
"KeyName" : { "Ref" : "KeyName" },
"SecurityGroupIds" : [
{ "Ref" : "SgSSH" },
{ "Ref" : "SgTungstenBridge" }
],
"SubnetId" : {"Ref": "SubnetA"},
"Tags" : [{"Key": "Name", "Value": "tungsten-bridge"}],
"Monitoring" : "False",
"Tenancy" : "default"
}
},
"TungstenBridgeEIP": {
"Type": "AWS::EC2::EIP",
"Properties": {
"InstanceId": { "Ref": "TungstenBridgeInstance" },
"Domain" : "vpc"
}
},
"TungstenSlaveDBSubnetGroup" : {
"Type" : "AWS::RDS::DBSubnetGroup",
"Properties" : {
"DBSubnetGroupDescription" : "tungsten-slave",
"SubnetIds" : [
{"Ref":"SubnetA"},
{"Ref":"SubnetB"}
]
}
},
"MySQLSlaveDBInstance" : {
"Type" : "AWS::RDS::DBInstance",
"Properties" : {
"DBInstanceClass" : "db.t1.micro",
"AllocatedStorage" : "5",
"Engine" : "mysql",
"MultiAZ" : "false",
"MasterUsername" : "root",
"MasterUserPassword" : {"Ref":"SlaveMasterPassword"},
"BackupRetentionPeriod" : "1",
"Tags" : [{"Key": "Name", "Value": "mysql-slave"}],
"DBSubnetGroupName" : {"Ref":"TungstenSlaveDBSubnetGroup"},
"VPCSecurityGroups" : [
{ "Ref" : "SgMySQL" }
]
}
}
},
"Outputs" : {
"SSHToTungstenMaster": {
"Value": { "Fn::Join":["", [
"ssh -i /path/to/", { "Ref": "KeyName" }, ".pem ec2-user@", { "Ref": "TungstenMasterEIP" }
]] },
"Description": "SSH command to connect tungsten-master"
},
"SSHToTungstenBridge": {
"Value": { "Fn::Join":["", [
"ssh -i /path/to/", { "Ref": "KeyName" }, ".pem ec2-user@", { "Ref": "TungstenBridgeEIP" }
]] },
"Description": "SSH command to connect tungsten-bridge"
},
"MySQLSlaveHostname" : {
"Value" : { "Fn::GetAtt" : ["MySQLSlaveDBInstance", "Endpoint.Address"] },
"Description" : "Hostname of mysql-slave"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment