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,
I have selected in my VM MyBB 1, Select File –> Export
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.
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
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
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
For the above error message.. need to configure the user in aws CLI, below step to configure the ec2 user.
file “credentials.csv
”
Once completed user configuration run “aws iam get-user
” command and you will get below screenshot showing the result.
Changed date time zone as per the region.
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.
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.
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
Check-in AMI: