User Guide / Using CloudFormation |
This topic describes a use case for creating a stack, checking the stack progress, and deleting the stack.
For this use case, we will use the following template:
{ "Parameters": { "MyImageId": { "Description":"Image id", "Type":"String" }, "MyKeyPair": { "Description":"Key Pair", "Type":"String" } }, "Resources" : { "MySecurityGroup": { "Type": "AWS::EC2::SecurityGroup", "Properties": { "GroupDescription" : "Security Group with Ingress Rule for MyInstance", "SecurityGroupIngress" : [ { "IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" } ] } }, "MyInstance": { "Type": "AWS::EC2::Instance", "Properties": { "ImageId" : { "Ref":"MyImageId" }, "SecurityGroups" : [ { "Ref" : "MySecurityGroup" } ], "KeyName" : { "Ref" : "MyKeyPair" } } } } }
This template creates an instance with a security group that allows global SSH access (port 22), but uses a keypair to log in. It requires two parameters, MyImageId, which is the image ID of the instance to create, and MyKeyPair, which is the name of the keypair to use to log in with. You can use both values with the euca-run-instances command to create an instance manually (for example, euca-run-instances -k mykey emi-db0b2276) so the arguments needed here are standard instance arguments.
The steps to run this template through the system are explained in the following steps.