Skip to content

Latest commit

 

History

History
 
 

lab08-cfn-init

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Lab 8: cfn-init

Making use of cfn-init to provision EC2 instances.

Overview

  1. Create a CloudFormation template using cfn-init.
  2. Create a CloudFormation stack based on your template.

Instructions

Create a template

  1. Open stub.yaml with an editor of your choice. The stub file contains a skeleton to start from.
  2. Install httpd with the help of cfn-init by adding metadata to EC2Instance (see Resource Type: CloudFormation Init).
  3. Create a file /var/www/html/index.html with <html><body>Hello World!</body></html> as content by adding metadata to EC2Instance (see Resource Type: CloudFormation Init).
  4. Start httpd with the help of cfn-init by adding metadata to EC2Instance (see Resource Type: CloudFormation Init).

Create a stack based on the template

  1. Open CloudFormation in AWS Management Console.
  2. Click Create Stack button.
  3. Select Upload a template to Amazon S3.
  4. Choose the template file you created for this lab.
  5. Click Next button.
  6. Insert lab8-$usernameas stack name. Replace $usernamewith your username (e.g. lab8-awittig).
  7. Select a random subnet and the only available VPC as Parameters.
  8. Click Next button.
  9. Skip next step by clicking on Next button.
  10. Review your input and click Create button.
  11. Wait until your stack reaches status CREATE_COMPLETE.
  12. Select your stack by clicking on row of the table.
  13. Switch to the Outputs tab.
  14. Search for WebsiteURL and click on the URL.
  15. A website showing Hello World! should appear.
  16. Select your stack by clicking on row of the table again.
  17. Select Delete Stack from the Actions menu.
  18. Confirm the deletion of your stack.
  19. Congratulations! You are done with the first lab!

Documentation

Sample solution

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.