Making use of cfn-init to provision EC2 instances.
- Create a CloudFormation template using cfn-init.
- 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. - Install
httpd
with the help of cfn-init by adding metadata toEC2Instance
(see Resource Type: CloudFormation Init). - Create a file
/var/www/html/index.html
with<html><body>Hello World!</body></html>
as content by adding metadata toEC2Instance
(see Resource Type: CloudFormation Init). - Start
httpd
with the help of cfn-init by adding metadata toEC2Instance
(see Resource Type: CloudFormation Init).
- 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
lab8-$username
as stack name. Replace$username
with your username (e.g. lab8-awittig). - Select a random subnet and the only available VPC as Parameters.
- 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.
- Switch to the Outputs tab.
- Search for WebsiteURL and click on the URL.
- A website showing
Hello World!
should appear. - Select your stack by clicking on row of the table again.
- Select Delete Stack from the Actions menu.
- Confirm the deletion of your stack.
- Congratulations! You are done with the first 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.