Skip to content

Instantly share code, notes, and snippets.

@rnhurt
Created April 3, 2015 02:26
Show Gist options
  • Save rnhurt/05aba51470032c09356c to your computer and use it in GitHub Desktop.
Save rnhurt/05aba51470032c09356c to your computer and use it in GitHub Desktop.
Cloud Formation Templates
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Project: {{ProjectName}}.",
"Mappings" : {
{{#each Mappings}}{{{this}}}
{{/each}}
},
"Conditions" : {
"USEast1" : { "Fn::Equals" : [{ "Ref" : "AWS::Region" }, "us-east-1" ]},
"USWest1" : { "Fn::Equals" : [{ "Ref" : "AWS::Region" }, "us-west-1" ]}
},
"Resources" : {
{{! --------------------------------------- }}
{{! Generic, non region specific, resources }}
{{! --------------------------------------- }}
"{{IAM::Role.Name}}" : {
"Type" : "AWS::IAM::Role",
"Properties" : { {{{IAM::Role.Properties}}} }
},
"{{IAM::InstanceProfile.Name}}" : {
"Type" : "AWS::IAM::InstanceProfile",
"Properties" : { {{{IAM::InstanceProfile.Properties}}} }
},
{{! ------------------------- }}
{{! Region Specific Resources }}
{{! ------------------------- }}
{{#each EnvRegions}}
{{#each ../SecurityGroups}}
"{{this.Name}}{{../Name}}" : {
"Type" : "AWS::EC2::SecurityGroup",
"Condition" : "{{../Name}}",
"Properties" : {
"GroupDescription" : "{{this.GroupDescription}}",
"VpcId" : "{{../VPCId}}",
"SecurityGroupIngress" : [
{{#each this.SecurityGroupIngress}}
{{#if this.FromPort}}
{ "IpProtocol" : "{{this.IpProtocol}}", "FromPort" : {{this.FromPort}}, "ToPort" : {{this.ToPort}}, "CidrIp" : "{{this.CidrIp}}" }{{#unless @last}},{{/unless}}
{{else}}
{ "IpProtocol" : "{{this.IpProtocol}}", "CidrIp" : "{{this.CidrIp}}" }{{#unless @last}},{{/unless}}
{{/if}}
{{/each}}
],
"SecurityGroupEgress" : [
{{#each this.SecurityGroupEgress}}
{{#if this.FromPort}}
{ "IpProtocol" : "{{this.IpProtocol}}", "FromPort" : {{this.FromPort}}, "ToPort" : {{this.ToPort}}, "CidrIp" : "{{this.CidrIp}}" }{{#unless @last}},{{/unless}}
{{else}}
{ "IpProtocol" : "{{this.IpProtocol}}", "CidrIp" : "{{this.CidrIp}}" }{{#unless @last}},{{/unless}}
{{/if}}
{{/each}}
],
"Tags" : [
{ "Key" : "Name", "Value" : "{{../../ProjectName}}: {{this.GroupDescription}}" },
{ "Key" : "Environment", "Value" : "{{../../EnvType}}" },
{ "Key" : "Project", "Value" : "{{../../ProjectName}}" }
]
}
},
{{/each}}
...
{{/each}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment