Last active
August 29, 2015 14:07
-
-
Save yustam/eae4c50c5e783f4df8af to your computer and use it in GitHub Desktop.
velocity-cfn-template-sample.template.vm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "$description", | |
"Resources" : { | |
"$security_group.name" : { | |
"Type" : "AWS::EC2::SecurityGroup", | |
"DeletionPolicy" : "Delete", | |
"Properties" : { | |
"GroupDescription" : "$security_group.description", | |
"SecurityGroupIngress" : [ | |
#foreach ( $ing in $security_group.ingress ) | |
#if ( $foreach.hasNext ) | |
{ "IpProtocol" : "$ing.protocol", "FromPort" : "$ing.from", "ToPort" : "$ing.to", "CidrIp" : "$ing.cidr" }, | |
#else | |
{ "IpProtocol" : "$ing.protocol", "FromPort" : "$ing.from", "ToPort" : "$ing.to", "CidrIp" : "$ing.cidr" } | |
#end | |
#end | |
] | |
} | |
}, | |
"$instance.name" : { | |
"Type" : "AWS::EC2::Instance", | |
"DeletionPolicy" : "Delete", | |
"Properties" : { | |
"Tags" : [ | |
{ "Key" : "Name", "Value" : "$instance.name" } | |
], | |
"ImageId" : "$instance.id", | |
"InstanceType" : "$instance.type", | |
"AvailabilityZone" : "$availability_zone", | |
"SecurityGroups" : [ { "Ref" : "$security_group.name" } ], | |
"UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [ | |
"#!/bin/bash -v\n", | |
"yum update -y aws-cfn-bootstrap\n", | |
"# wait for the EBS volume to show up\n", | |
#foreach ( $snapshot in $snapshots ) | |
"while [ ! -e $snapshot.device ]; do echo Waiting for EBS volume to attach; sleep 5; done\n", | |
#end | |
"# mount EBS volume\n", | |
#foreach ( $snapshot in $snapshots ) | |
"mount $snapshot.device $snapshot.path\n", | |
#end | |
"# start postgresql server\n", | |
"service postgresql start\n" | |
]]}} | |
} | |
}, | |
"$volume.name" : { | |
"Type" : "AWS::EC2::Volume", | |
"DeletionPolicy" : "Delete", | |
"Properties" : { | |
"AvailabilityZone" : "$availability_zone", | |
"Encrypted" : "false", | |
"VolumeType" : "$volume.type", | |
"Size" : "$volume.size" | |
} | |
}, | |
"MountPoint$volume.name" : { | |
"Type" : "AWS::EC2::VolumeAttachment", | |
"Properties" : { | |
"InstanceId" : { "Ref" : "$instance.name" }, | |
"VolumeId" : { "Ref" : "$volume.name" }, | |
"Device" : "$volume.device" | |
} | |
}, | |
#foreach ( $snapshot in $snapshots ) | |
#if ( $foreach.hasNext ) | |
"DatabaseVolume$snapshot.name" : { | |
"Type" : "AWS::EC2::Volume", | |
"DeletionPolicy" : "Delete", | |
"Properties" : { | |
"AvailabilityZone" : "$availability_zone", | |
"SnapshotId" : "$snapshot.id", | |
"Encrypted" : "false", | |
"VolumeType" : "$snapshot.type", | |
"Size" : "$snapshot.size" | |
} | |
}, | |
"MountPoint$snapshot.name" : { | |
"Type" : "AWS::EC2::VolumeAttachment", | |
"Properties" : { | |
"InstanceId" : { "Ref" : "$instance.name" }, | |
"VolumeId" : { "Ref" : "DatabaseVolume$snapshot.name" }, | |
"Device" : "$snapshot.device" | |
} | |
}, | |
#else | |
"DatabaseVolume$snapshot.name" : { | |
"Type" : "AWS::EC2::Volume", | |
"DeletionPolicy" : "Delete", | |
"Properties" : { | |
"AvailabilityZone" : "$availability_zone", | |
"SnapshotId" : "$snapshot.id", | |
"Encrypted" : "false", | |
"VolumeType" : "$snapshot.type", | |
"Size" : "$snapshot.size" | |
} | |
}, | |
"MountPoint$snapshot.name" : { | |
"Type" : "AWS::EC2::VolumeAttachment", | |
"Properties" : { | |
"InstanceId" : { "Ref" : "$instance.name" }, | |
"VolumeId" : { "Ref" : "DatabaseVolume$snapshot.name" }, | |
"Device" : "$snapshot.device" | |
} | |
} | |
} | |
#end | |
#end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment