Browse Source

cloudformation counter demo

master
Sebastian Rieger 7 years ago
parent
commit
f59580905e
  1. BIN
      aws-cloudformation-demo/cloudcomp-counter-demo-with-vpc-designer (1).png
  2. BIN
      aws-cloudformation-demo/cloudcomp-counter-demo-with-vpc-designer.png
  3. 280
      aws-cloudformation-demo/cloudcomp-counter-demo-with-vpc.json
  4. 151
      aws-cloudformation-demo/cloudcomp-counter-demo.json

BIN
aws-cloudformation-demo/cloudcomp-counter-demo-with-vpc-designer (1).png

Before

Width: 2046  |  Height: 2046  |  Size: 299 KiB

BIN
aws-cloudformation-demo/cloudcomp-counter-demo-with-vpc-designer.png

After

Width: 2163  |  Height: 2163  |  Size: 316 KiB

280
aws-cloudformation-demo/cloudcomp-counter-demo-with-vpc.json

@ -1,7 +1,6 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters":
{
"Parameters": {
"paramImageID": {
"Type": "AWS::EC2::Image::Id",
"Default": "ami-f573e19a",
@ -10,7 +9,11 @@
"paramInstanceType": {
"Type": "String",
"Default": "t2.nano",
"AllowedValues" : ["t2.nano", "t2.micro", "m1.small"],
"AllowedValues": [
"t2.nano",
"t2.micro",
"m1.small"
],
"Description": "Enter t2.micro, m1.small, or m1.large. Default is t2.micro."
},
"paramKeyPair": {
@ -28,11 +31,23 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"AssociatePublicIpAddress": true,
"ImageId": { "Ref" : "paramImageID" },
"InstanceType": { "Ref" : "paramInstanceType" },
"KeyName": { "Ref" : "paramKeyPair" },
"IamInstanceProfile": { "Ref" : "paramIamInstanceRole" },
"SecurityGroups": [ { "Ref": "sgCloudCompDemoSecurityGroup" } ],
"ImageId": {
"Ref": "paramImageID"
},
"InstanceType": {
"Ref": "paramInstanceType"
},
"KeyName": {
"Ref": "paramKeyPair"
},
"IamInstanceProfile": {
"Ref": "paramIamInstanceRole"
},
"SecurityGroups": [
{
"Ref": "sgCloudCompDemoSecurityGroup"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
@ -121,81 +136,150 @@
"CidrBlock": "10.0.0.0/16",
"EnableDnsSupport": "true",
"EnableDnsHostnames": "true",
"Tags" : [ {"Key" : "Name", "Value" : "vpcCloudCompCounterDemo"} ]
"Tags": [
{
"Key": "Name",
"Value": "vpcCloudCompCounterDemo"
}
]
}
},
"subnetCloudCompCounterDemoPublicSubnetAz1": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": { "Ref" : "vpcCloudCompCounterDemo" },
"VpcId": {
"Ref": "vpcCloudCompCounterDemo"
},
"CidrBlock": "10.0.0.0/24",
"AvailabilityZone" : { "Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
"Tags" : [ {"Key" : "Name", "Value" : "subnetCloudCompCounterDemoPublicSubnetAz1"} ]
"AvailabilityZone": {
"Fn::Select": [
"0",
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
},
"Tags": [
{
"Key": "Name",
"Value": "subnetCloudCompCounterDemoPublicSubnetAz1"
}
]
}
},
"subnetCloudCompCounterDemoPublicSubnetAz2": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": { "Ref" : "vpcCloudCompCounterDemo" },
"VpcId": {
"Ref": "vpcCloudCompCounterDemo"
},
"CidrBlock": "10.0.1.0/24",
"AvailabilityZone" : { "Fn::Select": [ "1", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
"Tags" : [ {"Key" : "Name", "Value" : "subnetCloudCompCounterDemoPublicSubnetAz2"} ]
"AvailabilityZone": {
"Fn::Select": [
"1",
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
},
"Tags": [
{
"Key": "Name",
"Value": "subnetCloudCompCounterDemoPublicSubnetAz2"
}
]
}
},
"igCloudCompCounterDemo": {
"Type": "AWS::EC2::InternetGateway",
"Properties": {
"Tags" : [ {"Key" : "Name", "Value" : "igCloudCompCounterDemo"} ]
"Tags": [
{
"Key": "Name",
"Value": "igCloudCompCounterDemo"
}
]
}
},
"attachGateway": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": { "Ref" : "vpcCloudCompCounterDemo" },
"InternetGatewayId": { "Ref" : "igCloudCompCounterDemo" }
"VpcId": {
"Ref": "vpcCloudCompCounterDemo"
},
"InternetGatewayId": {
"Ref": "igCloudCompCounterDemo"
}
}
},
"routetableViaIgw": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": { "Ref" : "vpcCloudCompCounterDemo" },
"Tags" : [ {"Key" : "Name", "Value" : "routetableViaIgw"} ]
"VpcId": {
"Ref": "vpcCloudCompCounterDemo"
},
"Tags": [
{
"Key": "Name",
"Value": "routetableViaIgw"
}
]
}
},
"publicrouteViaIgw": {
"Type": "AWS::EC2::Route",
"DependsOn": "attachGateway",
"Properties": {
"RouteTableId": { "Ref" : "routetableViaIgw" },
"RouteTableId": {
"Ref": "routetableViaIgw"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": { "Ref" : "igCloudCompCounterDemo" }
"GatewayId": {
"Ref": "igCloudCompCounterDemo"
}
}
},
"publicsubnet1RouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": { "Ref" : "subnetCloudCompCounterDemoPublicSubnetAz1" },
"RouteTableId": { "Ref" : "routetableViaIgw" }
"SubnetId": {
"Ref": "subnetCloudCompCounterDemoPublicSubnetAz1"
},
"RouteTableId": {
"Ref": "routetableViaIgw"
}
}
},
"publicsubnet1RouteTableAssociation": {
"publicsubnet2RouteTableAssociation": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"SubnetId": { "Ref" : "subnetCloudCompCounterDemoPublicSubnetAz2" },
"RouteTableId": { "Ref" : "routetableViaIgw" }
"SubnetId": {
"Ref": "subnetCloudCompCounterDemoPublicSubnetAz2"
},
"RouteTableId": {
"Ref": "routetableViaIgw"
}
}
},
"sgCloudCompDemoSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "CloudComp Counter Demo",
"VpcId": { "Ref": "vpcCloudCompCounterDemo" }
"VpcId": {
"Ref": "vpcCloudCompCounterDemo"
}
}
},
"ingress1": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "tcp",
"FromPort": "36037",
"ToPort": "36137",
@ -205,7 +289,9 @@
"ingress2": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
@ -215,7 +301,9 @@
"ingress3": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "udp",
"FromPort": "36037",
"ToPort": "36137",
@ -225,7 +313,9 @@
"egress1": {
"Type": "AWS::EC2::SecurityGroupEgress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "-1",
"CidrIp": "0.0.0.0/0"
}
@ -234,10 +324,32 @@
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": [
{ "Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
{ "Fn::Select": [ "1", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] }
{
"Fn::Select": [
"0",
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
},
{
"Fn::Select": [
"1",
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
}
],
"TargetGroupARNs": [
{
"Ref": "elbCloudCompTargetGroup"
}
],
"TargetGroupARNs": [ { "Ref": "elbCloudCompTargetGroup" } ],
"Cooldown": "30",
"DesiredCapacity": "1",
"HealthCheckGracePeriod": "60",
@ -245,8 +357,12 @@
"MaxSize": "3",
"MinSize": "1",
"VPCZoneIdentifier": [
{ "Ref" : "subnetCloudCompCounterDemoPublicSubnetAz1" },
{ "Ref" : "subnetCloudCompCounterDemoPublicSubnetAz2" }
{
"Ref": "subnetCloudCompCounterDemoPublicSubnetAz1"
},
{
"Ref": "subnetCloudCompCounterDemoPublicSubnetAz2"
}
],
"LaunchConfigurationName": {
"Ref": "lcVertSysAutoScaleConfigv11"
@ -266,7 +382,9 @@
]
}
],
"TerminationPolicies": [ "Default" ]
"TerminationPolicies": [
"Default"
]
}
},
"sgCloudCompScalePolicy": {
@ -280,9 +398,38 @@
"TargetValue": 5,
"PredefinedMetricSpecification": {
"PredefinedMetricType": "ALBRequestCountPerTarget",
"ResourceLabel": { "Fn::Join": [ "/", [
"app/elbCloudCompLoadBalancer", { "Fn::Select": [ "3", { "Fn::Split": [ "/", { "Ref": "elbCloudCompLoadBalancer" } ] } ] },
"targetgroup/elbCloudCompTargetGroup", { "Fn::Select": [ "2", { "Fn::Split": [ "/", { "Ref": "elbCloudCompTargetGroup" } ] } ] }
"ResourceLabel": {
"Fn::Join": [
"/",
[
"app/elbCloudCompLoadBalancer",
{
"Fn::Select": [
"3",
{
"Fn::Split": [
"/",
{
"Ref": "elbCloudCompLoadBalancer"
}
]
}
]
},
"targetgroup/elbCloudCompTargetGroup",
{
"Fn::Select": [
"2",
{
"Fn::Split": [
"/",
{
"Ref": "elbCloudCompTargetGroup"
}
]
}
]
}
]
]
}
@ -300,10 +447,18 @@
"IpAddressType": "ipv4",
"Type": "application",
"Scheme": "internet-facing",
"SecurityGroups": [ { "Ref": "sgCloudCompDemoSecurityGroup" } ],
"SecurityGroups": [
{
"Ref": "sgCloudCompDemoSecurityGroup"
}
],
"Subnets": [
{ "Ref" : "subnetCloudCompCounterDemoPublicSubnetAz1" },
{ "Ref" : "subnetCloudCompCounterDemoPublicSubnetAz2" }
{
"Ref": "subnetCloudCompCounterDemoPublicSubnetAz1"
},
{
"Ref": "subnetCloudCompCounterDemoPublicSubnetAz2"
}
]
}
},
@ -329,7 +484,9 @@
"HttpCode": "200"
},
"Name": "elbCloudCompTargetGroup",
"VpcId": { "Ref": "vpcCloudCompCounterDemo" }
"VpcId": {
"Ref": "vpcCloudCompCounterDemo"
}
}
},
"elbCloudCompListener": {
@ -343,25 +500,46 @@
"DefaultActions": [
{
"Type": "forward",
"TargetGroupArn": { "Ref": "elbCloudCompTargetGroup" }
"TargetGroupArn": {
"Ref": "elbCloudCompTargetGroup"
}
}
]
}
}
},
"Outputs":
{
"Outputs": {
"LoadBalancer": {
"Description": "Load Balancer",
"Value": { "Ref" : "elbCloudCompLoadBalancer" }
"Value": {
"Ref": "elbCloudCompLoadBalancer"
}
},
"LoadBalancerDns": {
"Description": "Load Balancer DNS",
"Value": { "Fn::GetAtt" : ["elbCloudCompLoadBalancer", "DNSName"] }
"Value": {
"Fn::GetAtt": [
"elbCloudCompLoadBalancer",
"DNSName"
]
}
},
"LoadBalancerURL": {
"Description": "Load Balancer URL",
"Value": { "Fn::Join": [ ":", [ { "Fn::GetAtt" : ["elbCloudCompLoadBalancer", "DNSName"] }, "36042/counter" ] ] }
"Value": {
"Fn::Join": [
":",
[
{
"Fn::GetAtt": [
"elbCloudCompLoadBalancer",
"DNSName"
]
},
"36042/counter"
]
]
}
}
},
"Description": "CloudComp Counter Demo"

151
aws-cloudformation-demo/cloudcomp-counter-demo.json

@ -1,7 +1,6 @@
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters":
{
"Parameters": {
"paramImageID": {
"Type": "AWS::EC2::Image::Id",
"Default": "ami-f573e19a",
@ -10,7 +9,11 @@
"paramInstanceType": {
"Type": "String",
"Default": "t2.nano",
"AllowedValues" : ["t2.nano", "t2.micro", "m1.small"],
"AllowedValues": [
"t2.nano",
"t2.micro",
"m1.small"
],
"Description": "Enter t2.micro, m1.small, or m1.large. Default is t2.micro."
},
"paramKeyPair": {
@ -40,11 +43,23 @@
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"AssociatePublicIpAddress": true,
"ImageId": { "Ref" : "paramImageID" },
"InstanceType": { "Ref" : "paramInstanceType" },
"KeyName": { "Ref" : "paramKeyPair" },
"IamInstanceProfile": { "Ref" : "paramIamInstanceRole" },
"SecurityGroups": [ { "Ref": "sgCloudCompDemoSecurityGroup" } ],
"ImageId": {
"Ref": "paramImageID"
},
"InstanceType": {
"Ref": "paramInstanceType"
},
"KeyName": {
"Ref": "paramKeyPair"
},
"IamInstanceProfile": {
"Ref": "paramIamInstanceRole"
},
"SecurityGroups": [
{
"Ref": "sgCloudCompDemoSecurityGroup"
}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
@ -131,13 +146,17 @@
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "CloudComp Counter Demo",
"VpcId": { "Ref": "paramVPC" }
"VpcId": {
"Ref": "paramVPC"
}
}
},
"ingress1": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "tcp",
"FromPort": "36037",
"ToPort": "36137",
@ -147,7 +166,9 @@
"ingress2": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "tcp",
"FromPort": "22",
"ToPort": "22",
@ -157,7 +178,9 @@
"ingress3": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "udp",
"FromPort": "36037",
"ToPort": "36137",
@ -167,7 +190,9 @@
"egress1": {
"Type": "AWS::EC2::SecurityGroupEgress",
"Properties": {
"GroupId": { "Ref": "sgCloudCompDemoSecurityGroup" },
"GroupId": {
"Ref": "sgCloudCompDemoSecurityGroup"
},
"IpProtocol": "-1",
"CidrIp": "0.0.0.0/0"
}
@ -175,15 +200,23 @@
"asgCloudCompAutoScaleGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": { "Ref" : "paramAvailabilityZones" },
"TargetGroupARNs": [ { "Ref": "elbCloudCompTargetGroup" } ],
"AvailabilityZones": {
"Ref": "paramAvailabilityZones"
},
"TargetGroupARNs": [
{
"Ref": "elbCloudCompTargetGroup"
}
],
"Cooldown": "30",
"DesiredCapacity": "1",
"HealthCheckGracePeriod": "60",
"HealthCheckType": "EC2",
"MaxSize": "3",
"MinSize": "1",
"VPCZoneIdentifier": { "Ref": "paramSubnetIDs" },
"VPCZoneIdentifier": {
"Ref": "paramSubnetIDs"
},
"LaunchConfigurationName": {
"Ref": "lcVertSysAutoScaleConfigv11"
},
@ -202,7 +235,9 @@
]
}
],
"TerminationPolicies": [ "Default" ]
"TerminationPolicies": [
"Default"
]
}
},
"sgCloudCompScalePolicy": {
@ -216,9 +251,38 @@
"TargetValue": 5,
"PredefinedMetricSpecification": {
"PredefinedMetricType": "ALBRequestCountPerTarget",
"ResourceLabel": { "Fn::Join": [ "/", [
"app/elbCloudCompLoadBalancer", { "Fn::Select": [ "3", { "Fn::Split": [ "/", { "Ref": "elbCloudCompLoadBalancer" } ] } ] },
"targetgroup/elbCloudCompTargetGroup", { "Fn::Select": [ "2", { "Fn::Split": [ "/", { "Ref": "elbCloudCompTargetGroup" } ] } ] }
"ResourceLabel": {
"Fn::Join": [
"/",
[
"app/elbCloudCompLoadBalancer",
{
"Fn::Select": [
"3",
{
"Fn::Split": [
"/",
{
"Ref": "elbCloudCompLoadBalancer"
}
]
}
]
},
"targetgroup/elbCloudCompTargetGroup",
{
"Fn::Select": [
"2",
{
"Fn::Split": [
"/",
{
"Ref": "elbCloudCompTargetGroup"
}
]
}
]
}
]
]
}
@ -236,8 +300,14 @@
"IpAddressType": "ipv4",
"Type": "application",
"Scheme": "internet-facing",
"SecurityGroups": [ { "Ref": "sgCloudCompDemoSecurityGroup" } ],
"Subnets": { "Ref": "paramSubnetIDs" }
"SecurityGroups": [
{
"Ref": "sgCloudCompDemoSecurityGroup"
}
],
"Subnets": {
"Ref": "paramSubnetIDs"
}
}
},
"elbCloudCompTargetGroup": {
@ -262,7 +332,9 @@
"HttpCode": "200"
},
"Name": "elbCloudCompTargetGroup",
"VpcId": { "Ref": "paramVPC" }
"VpcId": {
"Ref": "paramVPC"
}
}
},
"elbCloudCompListener": {
@ -276,25 +348,46 @@
"DefaultActions": [
{
"Type": "forward",
"TargetGroupArn": { "Ref": "elbCloudCompTargetGroup" }
"TargetGroupArn": {
"Ref": "elbCloudCompTargetGroup"
}
}
]
}
}
},
"Outputs":
{
"Outputs": {
"LoadBalancer": {
"Description": "Load Balancer",
"Value": { "Ref" : "elbCloudCompLoadBalancer" }
"Value": {
"Ref": "elbCloudCompLoadBalancer"
}
},
"LoadBalancerDns": {
"Description": "Load Balancer DNS",
"Value": { "Fn::GetAtt" : ["elbCloudCompLoadBalancer", "DNSName"] }
"Value": {
"Fn::GetAtt": [
"elbCloudCompLoadBalancer",
"DNSName"
]
}
},
"LoadBalancerURL": {
"Description": "Load Balancer URL",
"Value": { "Fn::Join": [ ":", [ { "Fn::GetAtt" : ["elbCloudCompLoadBalancer", "DNSName"] }, "36042/counter" ] ] }
"Value": {
"Fn::Join": [
":",
[
{
"Fn::GetAtt": [
"elbCloudCompLoadBalancer",
"DNSName"
]
},
"36042/counter"
]
]
}
}
},
"Description": "CloudComp Counter Demo"
Loading…
Cancel
Save