Skip to content

Instantly share code, notes, and snippets.

@winebarrel
Created March 10, 2014 15:55
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/9467752 to your computer and use it in GitHub Desktop.
Save winebarrel/9467752 to your computer and use it in GitHub Desktop.
Kumogata: Post command
Resources do
MyInstance do
Type "AWS::EC2::Instance"
Properties do
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-signal -e 0 '<%= Ref "WaitHandle" %>'
EOS
end
end # Properties
end
WaitHandle do
Type "AWS::CloudFormation::WaitConditionHandle"
end
WaitCondition do
Type "AWS::CloudFormation::WaitCondition"
DependsOn "MyInstance"
Properties do
Handle { Ref "WaitHandle" }
Timeout 300
end
end
end
Outputs do
MyPublicIp do
Value { Fn__GetAtt "MyInstance", "PublicIp" }
end
end
_post do
my_shell_command do
command <<-EOS
echo <%= Key "MyPublicIp" %>
EOS
end
my_ssh_command do
ssh do
host { Key "MyPublicIp" }
user "ec2-user"
end
command <<-EOS
hostname
EOS
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment