Wondering how to use VM Import/Export to Create EC2 Instance? We can help you.
Recently, one of our customers wanted to create a copy of his on-premises server on AWS as an Amazon EC2 instance.
Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.
Today, let us see how to use VM Import/Export to do that.
Use VM Import/Export to Create EC2 Instance
Generally, to run a VM Import/Export job, we use the AWS Command Line Interface.
It then creates a copy of the server as an AMI and uploads it to an Amazon S3 bucket. We can launch the AMI as an EC2 instance.
In order to avoid errors while we run the AWS CLI commands, we use the most recent version of the AWS CLI.
Our Support Techs recommend doing the following before we start:
- The VM must meet all the VM import/export requirements.
- We should review the supported Linux and Windows OS’, image formats, licensing options, and limitations of VM Import/Export.
- If we sign in as an AWS IAM user, we ensure to have the required permissions for IAM users in the policy.
1. We need to follow the guidelines in the Required configuration for VM export.
2. Initially, we install the AWS CLI on an on-premises client and configure it with the AWS credentials for the VM import user.
3. After that, in the AWS Region where we plan to run the EC2 instance we create a new S3 bucket.
4. Then we create the IAM role, “vmimport” with the trust policy that allows the VM import service to assume the role.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": { "Service": "vmie.amazonaws.com" },
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals":{
"sts:Externalid": "vmimport"
}
}
}
]
}
5. In addition, we need to attach the “vmimport” policy to the IAM role to grant permissions.
Here, make sure to replace the disk-image-file-bucket with the S3 bucket name.
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action":[
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket"
],
"Resource":[
"arn:aws:s3:::disk-image-file-bucket",
"arn:aws:s3:::disk-image-file-bucket/*"
]
},
{
"Effect":"Allow",
"Action":[
"ec2:ModifySnapshotAttribute",
"ec2:CopySnapshot",
"ec2:RegisterImage",
"ec2:Describe*"
],
"Resource":"*"
}
]
}
6. Eventually, we upload the image to the S3 bucket with any tool.
7. Next we run the AWS CLI command import-image from the client machine.
8. Then to check the import task status, we run:
describe-import-image-tasks
9. Once done, we follow the instructions for Launching an Instance Using the Launch Instance Wizard.
[Need help with the task? We’d be happy to assist you]
Conclusion
In short, we saw how our Support Techs make use of the VM Import/Export to Create EC2 instances.
0 Comments