Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save suz-lab/067f6d9ec86598521bad to your computer and use it in GitHub Desktop.
Save suz-lab/067f6d9ec86598521bad to your computer and use it in GitHub Desktop.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"ProjectName": {
"Type": "String",
"Default": "Cloudpack"
},
"PublicHostedZoneName": {
"Type": "String"
},
"CommonSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup::Id"
},
"Public1Subnet": {
"Type": "AWS::EC2::Subnet::Id"
},
"Public2Subnet": {
"Type": "AWS::EC2::Subnet::Id"
}
},
"Resources": {
"WwwLoadBalancer": {
"Type": "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties": {
"LoadBalancerName": { "Fn::Join" : [ "", [
{ "Ref": "ProjectName" },
"Www"
] ] },
"CrossZone": "true",
"Listeners": [ {
"LoadBalancerPort": "80",
"InstancePort": "80",
"Protocol": "HTTP"
} ],
"SecurityGroups": [
{ "Ref": "CommonSecurityGroup" }
],
"Subnets": [
{ "Ref": "Public1Subnet" },
{ "Ref": "Public2Subnet" }
],
"Tags": [ {
"Key": "Name",
"Value": { "Fn::Join" : [ "", [
{ "Ref": "ProjectName" },
"Www"
] ] }
} ]
}
},
"PublicHostedZone": {
"Type": "AWS::Route53::HostedZone",
"Properties": {
"Name": { "Ref": "PublicHostedZoneName" },
"HostedZoneTags": [ {
"Key": "Name",
"Value": { "Fn::Join" : [ "", [
{ "Ref": "ProjectName" },
"Public"
] ] }
} ]
}
},
"WwwPublicRecordSet": {
"Type": "AWS::Route53::RecordSet",
"Properties": {
"HostedZoneId": { "Ref": "PublicHostedZone" },
"Name": { "Fn::Join" : [ "", [
"www.",
{ "Ref": "PublicHostedZoneName" },
"."
] ] },
"Type": "A",
"AliasTarget" : {
"HostedZoneId": { "Fn::GetAtt": [ "WwwLoadBalancer", "CanonicalHostedZoneNameID" ] },
"DNSName": { "Fn::GetAtt": [ "WwwLoadBalancer", "CanonicalHostedZoneName" ] }
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment