Recently we decided to migrate our instances to a newly created EC2 account. I was assigned the task of migration and initially my impression of work was that it would only involve fiddling with aws credentials and I'd be done. However I couldn't have been any wrong. Migration of instances from one EC2 account to new one was a job in itself for me. Following are the steps which I had to follow to migrate the instances:1. Create AWS key pair for new account.
2. Create X.509 certificate for new account.
There are separate procedures which I too to migrate Linux and Windows instances.
Linux instance migration:
1. Copy X.509 certificate to some directory on instance which we want to migrate. I copied private key and certificate to /opt/ec2/keys directory.
2. Login to instance.
3. Download and extract ec2-ami-tools to /opt/ec2.
4. Set a variable EC2_HOME: export EC2_HOME=/opt/ec2
5. Set PATH: export PATH=$PATH:$EC2_HOME/bin
6. Bundle the instance:
ec2-bundle-vol -d /mnt -k /opt/ec2/keys/pk-XXX.pem -c /opt/ec2/keys/cert-XXX.pem -u XXXXXXXXX -e /opt/ec2 -s 10000
For details of using ec2-bundle-vol, use --help
7. Upload bundle: before uploading bundle I create a S3 bucket called ami_from_other_account on my newly created account.
ec2-upload-bundle -b ami_from_other_account -m /mnt/image.manifest.xml -a XXXXX -s XXXXXX
8. Register the AMI: in order to register the AMI we need ec2-api-tools and they need to be setup properly. One needs JRE and JAVA_HOME variable appropriately set. I had setup ec2-api-tools on my machine. I had also copied private key and certificate files to /opt/ec2/keys on my machine
The private key and Certificate are one's for newly created account.
ec2-register ami_from_other_account/image.manifest.xml -K /opt/ec2/keys/pk-XXX.pem -C /opt/ec2/keys/cert-XXX.pem -n AMI-Blah-Blah-Blah.
Windows instance migration:
1. Download and extract ec2-ami-tools and ec2-api-tools to /opt/ec2 directory.
2. Download private key and certificate file to /opt/ec2/keys
3. Share AMI of existing Windows instance with other user.
4. Run the instance thru new user account.
5. I created a S3 bucket called win_fac to hold my new AMI files
6. Bundle running instance
ec2-bundle-instance i-XXXX -b win_fac -o AWS_ACCESS_KEY -w AWS_SECRET_KEY
7. Register new AMI
ec2-register win_fac/image.manifest.xml -K /opt/ec2/keys/pk-XXX.pem -C /opt/ec2/keys/cert-XXX.pem -n WIN_AMI.
0 comments:
Post a Comment