This repository contains a simple example of using Packer to create an Amazon Machine Image (AMI) that runs Redis.
To build the AMI, follow the below steps:
- Packer installed on your local machine
- An AWS account
- Your AWS access credentials (AWS Access Key ID and Secret Access Key)
- Git installed on local machine
-
Clone this repository to your local machine using Git:
git clone [email protected]:sirishacyd/ami-to-build-redis.git
-
Navigate to the directory containing the repository:
cd ami-to-build-redis.git
-
Set your AWS credentials as environment variables:
export AWS_ACCESS_KEY=<your-aws-access-key> export AWS_SECRET_KEY=<your-aws-secret-key> export AWS_REGION=<aws-region>
-
Validate the Packer template to make sure there are no errors:
packer validate packer_template.json
-
If the template is valid, build the AMI using Packer:
packer build packer_template.json
-
Packer will begin building the AMI. This may take a few minutes.
-
Once the build is complete, Packer will output the ID of the new AMI.
-
==> Wait completed after 6 minutes 53 seconds
==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs: AMIs were created:
ap-south-1: ami-06a1ded2dc005181d
ssh -i "test.pem" [email protected]
cd /home/redisbuilder/redis/src
./redis-server