How to do it...

  1. Create a new Packer template file, and start by defining an amazon-ebs builder in the builders section:
      "builders": [         {           "type": "amazon-ebs",           "instance_type": "t2.micro",           "region": "us-east-1",           "source_ami": "ami-9be6f38c",           "ssh_username": "ec2-user",           "ami_name": "aws-linux-apache {{timestamp}}"         }       ],
The entire template file must be a valid JSON object. Remember to enclose the sections in curly braces: { ... }.
  1. Create a provisioners section, and include the following snippet to install and activate Apache:
      "provisioners": [         {           "type": "shell",           "inline": [             "sudo yum install -y httpd",             "sudo chkconfig httpd on"           ]         }       ]
  1. Save the file with a specific name, such as 04-creating-machine-images.json.
  1. Validate ...

Get AWS Administration Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.