In this Article we will explain how to bundle an instance which already has cPanel installed in it. The only thing you need to consider is cPanel licensing as cPanel provides license for the Elastic IP address. The article assumes that cPanel is licensed to an Elastic IP and the IP is still with us so that it can be reassigned to the new instance once its launched.
Why should we bundle a cPanel EC2 instance:
Many times we have seen issues like instances becoming unresponsive or not reachable by SSH etc. In such cases if we have a an AMI bundled and ready to start, we can go live in less than 5 minutes. We could save our clients by launching the AMIs with cPanel in couple of instances where the EC2 instances became unresponsive.
Here, we will re bundle a running EC2 instance into a new image (AMI).
1) Download the EC2 API and AMI tools and set up some environment variables to help the bundle.
[shell]
export EC2_HOME=/path/to/api/tools
export PATH=$PATH:$EC2_HOME/bin
export EC2_AMITOOL_HOME=/path/to/ami/tools
export PATH=$PATH:$EC2_AMITOOL_HOME/bin
export JAVA_HOME=/path/to/java
export EC2_PRIVATE_KEY=/path/to/key
export EC2_CERT=/path/to/cert
[/shell]
2) Bundle the files on the current instance into a copy of the image under /mnt
[shell]
ec2-bundle-vol
-r x86_64 \
-d /mnt \
-p “cPanel_ami” \
-u $aws_user \
-k /mnt/pk-*.pem \
-c /mnt/cert-*.pem \
-s 10240 \
-e /mnt,/root/.ssh
[/shell]
3) Upload the bundle to a bucket in S3
[shell]
ec2-upload-bundle \
-b $bucket \
-m /mnt/cPanel_ami.manifest.xml \
-a aws_accesskey \
-s aws_secretaccesskey
[/shell]
4) After all the files have been uploaded to Amazon S3 you need to register the new image as a new cPanel AMI
[shell]
ec2-register -n “$bucket/cPanel_ami” $bucket/cPanel_ami.manifest.xml
[/shell]
This will return an output like
[shell]
IMAGE ami-111111
[/shell]
This is the ami id of your new cPanel image.
done !
You are now ready with a cPanel installed AMI. Make sure that the elastic ip that you attach to the new cPanel instance has a valid cPanel license.