Skip to content

Instantly share code, notes, and snippets.

@winebarrel
Created March 9, 2014 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winebarrel/9b9bc263c0b80b1d4ca4 to your computer and use it in GitHub Desktop.
Save winebarrel/9b9bc263c0b80b1d4ca4 to your computer and use it in GitHub Desktop.
Resources do
[:cthulhu, :hastur, :nyar].each {|name|
_(name) do
Type "AWS::EC2::Instance"
Properties do
# amzn-ami-pv-2013.09.2.x86_64-ebs
ImageId "ami-0d13700c"
InstanceType "t1.micro"
KeyName "XXX"
NetworkInterfaces [
_{
DeviceIndex 0
SubnetId "subnet-XXXXXXXX"
AssociatePublicIpAddress true
}
]
UserData do
Fn__Base64 (<<-EOS).fn_join
#!/bin/bash
/opt/aws/bin/cfn-init -s <%= Ref "AWS::StackName" %> -r #{name} --region <%= Ref "AWS::Region" %>
/opt/aws/bin/cfn-signal -e 0 '<%= Ref "#{name}WaitHandle" %>'
EOS
end
Tags [
_{
Key "Name"
Value name
}
]
end # Properties
Metadata do
AWS__CloudFormation__Init do
config do
commands do
setup_command do
command (<<-EOS).fn_join
echo `hostname` > /tmp/hostname
EOS
end
end
end
end
end
end
_("#{name}WaitHandle") do
Type "AWS::CloudFormation::WaitConditionHandle"
end
_("#{name}WaitCondition") do
Type "AWS::CloudFormation::WaitCondition"
DependsOn name
Properties do
Handle { Ref "#{name}WaitHandle" }
Timeout 300
end
end
} # end of each
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment