Packer is a free, open source application from Hashicorp. It can generate a server image based on an existing one, and configure it for your special needs. You can use the generated image when you launch a server instance in the cloud or on your local workstation.
- Download Packer from https://www.packer.io/downloads.html,
- Unzip the downloaded ZIP file,
- Create a version-specific folder and a symbolic link based on Keep multiple versions of applications on Macintosh.
- Place the packer application into the version-specific folder you just created.
Generate the server image with Packer
- Open a Bash window,
- Navigate to the folder of the Packer JSON script,
- Execute the following command. Get the AWS access key and secret key from the ~/.aws/credentials file on your Macintosh or Linux workstation. On Windows, the file is at C:\Users\YOUR_USER_NAME\.aws\credentials.
packer build -var 'aws_access_key=MY_ACCESS_KEY' -var 'aws_secret_key=MY_SECRET_KEY' ./MY_PACKER_SCRIPT.json
- The command window will display the ID of the generated image, or you can find it by name in the EC2 section of the AWS console under AMIs.
Share the generated server image with other cloud accounts
If you work in multiple cloud accounts you need to share the generated server image with other accounts
- Log into the AWS account you have used to generate the server image,
- On the left side of the EC2 section select AMI and find the new image by name of ID,
- On the Permissions tab click the Edit button,
- Make sure the Private radio button is selected if you don’t want to share the image publicly,
- Enter the account number of the account you want to share the image with,
- Check the Add “create volume” permissions… checkbox,
- Click the Add Permission button,
- When you have added all accounts to share with, click the Save button.