In this tutorial you will build a t2.micro Amazon EC2 AMI.
The following section contains a complete Packer template that can be used to build an AWS Ubuntu AMI in the
Create a file named
aws-ubuntu.pkr.hcl and add the following code:
Authenticate to AWS
Before you can build the AMI, you need to provide your AWS credentials to Packer as environment variables.
These credentials should have permissions to create, modify and delete EC2 instances.
For the full list IAM permissions required to run the amazon-ebs builder perform a google search.
Add your AWS credentials as two environment variables,
You may need to also export your
AWS_SESSION_EXPIRATION as environment variables.
$ export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
> set AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
Run through the following Pack commands to build the image(s):
Initialize your Packer configuration.
Visit the AWS AMI Wizard page in the same region to verify that Packer successfully built your AMI.