Kumogata: Post command
This file contains 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
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