Importing your VM’s into AWS Using VM Import/Export.

Importing your VM’s into AWS Using VM Import/Export.

 

This lab will describe to importing your VM machine from the virtual box (oracle product) to AWS EC2 AMI. First, we will export the VM, please find the below steps I took to export VM,

virtual-box-image

I have selected in my VM MyBB 1, Select File –> Export

vm-export

export-process

export VM process started. It will take a few minutes. It depends upon your VM’s.

file saved in my Ubuntu desktop system “/home/balaji/Documents/MyBB.ova” ( you can save in the different path in your system).

Log in to the AWS Console and go to the IAM service.

aws-iam-servi e

add-user

assign-policy

user-tags

added-user

roles

create-roles

role1

roles2

roles3

roles4

roles5

roles6

roles7

roles8

roles9

roles10

 

Create EC2 instance to export VM to AMI. ( Workshop system windows 2012r2 server)
Once installed windows server download aws command-line utility using below URL
https://s3.amazonaws.com/aws-cli/AWSCLI64PY3.msi

aws-tool1 aws-tool2 aws-tool3 aws-tool4 aws-tool5 aws-tool6 aws-tool7

Create script below example container.json modify as we required,

The following is an example containers.json file.

[ {
"Description": "My Server OVA",
"Format": "ova",
"UserBucket": {
"S3Bucket": "my-import-bucket",
"S3Key": "vms/my-server-vm.ova"
}
}]

Below my scenario required format,

[ {
"Description": "MyBB Server OVA",
"Format": "ova",
"UserBucket": {
"S3Bucket": "importexportvm-bkt",
"S3Key": "MyBB.ova"
}
}]

Before running above command create a folder in windows under the C:\AWS

34 35

 

Executed the containers.json file by following command via CLI,

aws import-image --description "Windows 2008 image" --disk-containers file://containers.json

aws ec2 import-image --description “ MyBB Server OVA” --disk-containers “file://containers.json” --region us-west-2 --profile balajivadivel

36

For the above error message.. need to configure the user in aws CLI, below step to configure the ec2 user.

37

file “credentials.csv

Once completed user configuration run “aws iam get-user” command and you will get below screenshot showing the result.

38 39

Changed date time zone as per the region.vmimport-error

I am getting the above error and problem issue I haven’t added the Trust relationships and attach the same role to the EC2. So do the below steps to be followed.

associate-iam-role

Click Edit trust relationship and add the below code.

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": "vmie.amazonaws.com"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "vmimport"
}
}
}
]
}

Below screen to attach a role to the EC2 server (Windows2012r2server in my workshop)

Go to the EC2 instance and select the instance --> Actions --> Instance settings --> Attach/Replace IAM Role.
aws-IAM-role

Run the below command in EC2 CLI.

aws ec2 import-image --description “ MyBB Server OVA” --disk-containers “file://containers.json” --region us-west-2 --profile balajivadivel

aws ec2 describe-import-image-tasks –import-task-ids import-ami-0e192f98f4be83c73 –region us-west-2 –profile balajivadivel
aws-import-command

Check-in AMI:

AMI-Attach

Posted in: AWS Filed under:

Leave a Reply

Your email address will not be published. Required fields are marked *