Create an Amazon Machine Image (AMI) from a FreePBX Virtual Machine (VM)
important
- I opted to use VMware Workstation 15 Pro for this demonstration.
- Make sure to install and configure AWS Command Line Interface in your host computer. You can find the instructions here.
- Please use an IAM user with administrator privileges.
- I opted to use VMware Workstation 15 Pro for this demonstration.
- Make sure to install and configure AWS Command Line Interface in your host computer. You can find the instructions here.
- Please use an IAM user with administrator privileges.
- Download the latest FreePBX Distro from here and install it on VMware Workstation.
- SSH into the instance and install the following packages.
- Do the following changes in /etc/cloud/cloud.cfg
- Do the following changes in /etc/ssh/sshd_config
- Shutdown the VM and export it to an OVA file.
- Create an S3 bucket and upload the OVA file either using AWS CLI or a GUI tool. I used Cyberduck S3 Client and it can be downloaded here.
tip
- S3 Bucket: ami-storage
- OVA File: FreePBX.ova
- S3 Bucket: ami-storage
- OVA File: FreePBX.ova
- Create the following policy documents. Make sure to change S3 bucket and OVA file name according to your configurations.
- trust-policy.json will be used to create vmimport IAM role.
- role-policy.json will be used to assign necessary IAM policies to the vmimport role.
- containers.json will be used to generate an AMI from the uploaded OVA.
trust-policy.json
role-policy.json
containers.json
- Create vmimport IAM role.
- Create and assign necessary IAM policies to the vmimport role.
- Generate an AMI from the uploaded OVA.
tip
This will launch a task that will take about 15 to 60 minutes to complete. You can check its progress with the following command by replacing the ImportTaskId displayed in the above command.
tip
The task will remain active with "StatusMessage": "pending" until it finishes. The "Progress" attribute will indicate the percentage of work made up to that point. The task will be finished when the state changes "completed" and the previous command shows additional information about the already converted image to AMI format. From then on you will have a new AMI available in the same region where you created the S3 bucket and it will be ready to launch a new EC2 instance.
References: