Created
December 1, 2016 06:44
-
-
Save SteveHoggNZ/2319b3bf3c30a2f1876c0dbf7aaba5c6 to your computer and use it in GitHub Desktop.
CloudFormation / WaitCondition / WaitConditionHandler example
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", | |
"Mappings" : { | |
"RegionMap" : { | |
"us-east-1" : { | |
"AMI" : "ami-76f0061f" | |
}, | |
"us-west-1" : { | |
"AMI" : "ami-655a0a20" | |
}, | |
"eu-west-1" : { | |
"AMI" : "ami-7fd4e10b" | |
}, | |
"ap-northeast-1" : { | |
"AMI" : "ami-8e08a38f" | |
}, | |
"ap-southeast-1" : { | |
"AMI" : "ami-72621c20" | |
}, | |
"ap-southeast-2" : { | |
"AMI" : "ami-db704cb8" | |
} | |
} | |
}, | |
"Resources" : { | |
"SSHServerSecurityGroup" : { | |
"Type" : "AWS::EC2::SecurityGroup", | |
"Properties" : { | |
"VpcId" : "vpc-fdcfd098", | |
"GroupDescription" : "Allow SSH access", | |
"SecurityGroupIngress" : [ | |
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "<REDACTED>"} | |
] | |
} | |
}, | |
"Ec2Instance" : { | |
"Type" : "AWS::EC2::Instance", | |
"Properties" : { | |
"UserData" : { "Fn::Base64" : {"Ref" : "myWaitHandle"}}, | |
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, | |
"KeyName" : "SHTestKey", | |
"InstanceType" : "t2.micro", | |
"NetworkInterfaces" : [ { | |
"AssociatePublicIpAddress" : "true", | |
"DeviceIndex" : "0", | |
"GroupSet" : [ {"Ref" : "SSHServerSecurityGroup"} ], | |
"SubnetId" : "subnet-eccc6988" | |
} ], | |
} | |
}, | |
"myWaitHandle" : { | |
"Type" : "AWS::CloudFormation::WaitConditionHandle", | |
"Properties" : { | |
} | |
}, | |
"myWaitCondition" : { | |
"Type" : "AWS::CloudFormation::WaitCondition", | |
"DependsOn" : "Ec2Instance", | |
"Properties" : { | |
"Handle" : { "Ref" : "myWaitHandle" }, | |
"Timeout" : "4500" | |
} | |
}, | |
"Ec2Instance2" : { | |
"Type" : "AWS::EC2::Instance", | |
"DependsOn": "myWaitCondition", | |
"Properties" : { | |
"UserData" : { "Fn::Base64" : { "Fn::GetAtt" : [ "myWaitCondition", "Data" ] }}, | |
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]}, | |
"KeyName" : "SHTestKey", | |
"InstanceType" : "t2.micro", | |
"NetworkInterfaces" : [ { | |
"AssociatePublicIpAddress" : "true", | |
"DeviceIndex" : "0", | |
"GroupSet" : [ {"Ref" : "SSHServerSecurityGroup"} ], | |
"SubnetId" : "subnet-eccc6988" | |
} ], | |
} | |
} | |
}, | |
"Outputs" : { | |
"ApplicationData" : { | |
"Value" : { "Fn::GetAtt" : [ "myWaitCondition", "Data" ]}, | |
"Description" : "The data passed back as part of signalling the WaitCondition." | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment