CloudFormation detects dependencies between resources and creates, updates, or deletes the resources in the correct order.
- Create a CloudFormation template defining dependencies between resources.
- Create a CloudFormation stack based on your template.
- Open
stub.yaml
with an editor of your choice. The stub file contains a skeleton to start from. - Add a reference to
SecurityGroup
to the list ofSecurityGroupIds
of the EC2 instance (see Reference function). - Add a reference to the parameter
KeyName
to theKeyName
of the EC2 instance (see Reference function).
- Open CloudFormation in AWS Management Console.
- Click Create Stack button.
- Select Upload a template to Amazon S3.
- Choose the template file you created for this lab.
- Click Next button.
- Insert
lab5-$username
as stack name. Replace$username
with your username (e.g. lab5-awittig). - Select a random subnet as parameter for Subnet.
- Select a random key as parameter for Key Pair.
- Insert
ami-bff32ccc
(eu-west-1) orami-bc5b48d0
(eu-central-1) as parameter for AMI. - Insert
http://widdix.net/
or a website you own for URL. - Click Next button.
- Skip next step by clicking on Next button.
- Review your input and click Create button.
- Wait until your stack reaches status CREATE_COMPLETE.
- Select your stack by clicking on row of the table.
- Change to the Outputs tab.
- Find value of
InstanceId
and note it down. - Select the EC2 service from the main navigation.
- Search for an EC2 instance with the instance id from the outputs tab.
- Select the EC2 instance by clicking on the row of the table.
- Search for the Security Group attached to the EC2 instance and check if it allows incoming traffic to port 22.
- Switch back to the CloudFormation service.
- Select your stack by clicking on row of the table.
- Select Delete Stack from the Actions menu.
- Confirm the deletion of your stack.
- Congratulations! You are done with the lab!
This lab includes a sample solution sample-solution.yaml
. Use it if you are stuck during the creation of your template of if you want to review your results.