Jim's Blog
Toggle navigation
Jim's Blog
Home
About Me
Archives
Tags
How to Import Virtual Machine Image into AWS
2016-06-03 06:47:30
416
0
0
jim
## Prepare Virtual Machine * Install OS on VMware or VirtualBox * Startup OS, **delete the symbolic link of grubenv**, then copy the real grubenv file here, like this: ```bash cd /boot/grub2/ rm –f grubenv cp /boot/efi/EFI/centos/grubenv ./ ``` ## Export VM and Upload into AWS * Shutdown OS, export image using OVA type. * Login AWS console, then upload this OVA image into S3 bucket, for example: vm-import * Create vmimport role ```bash aws iam create-role --role-name vmimport \ --assume-role-policy-document file://trust-policy.json ``` Here is the content of trust-policy.json ```json { "Version":"2012-10-17", "Statement":[ { "Sid":"", "Effect":"Allow", "Principal":{ "Service":"vmie.amazonaws.com" }, "Action":"sts:AssumeRole", "Condition":{ "StringEquals":{ "sts:ExternalId":"vmimport" } } } ] } ``` * Edit policy for vmiport ```bash aws iam put-role-policy --role-name vmimport \ --policy-name vmimport \ --policy-document file://role-policy.json ``` Here is the content of role-policy.json ```json { "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "s3:ListBucket", "s3:GetBucketLocation" ], "Resource":[ "arn:aws:s3:::vm-import" ] }, { "Effect":"Allow", "Action":[ "s3:GetObject" ], "Resource":[ "arn:aws:s3:::vm-import/*" ] }, { "Effect":"Allow", "Action":[ "ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe*" ], "Resource":"*" } ] } ``` * Do the import task: ```bash aws ec2 import-image --cli-input-json ' { "Description": "OS OVA", "DiskContainers": [ { "Description": "CLI Task", "UserBucket": { "S3Bucket": "vm-import", "S3Key" : "os.ova" } } ] } ' ``` Here, *os.ova* is the name of vmware image which has been uploaded to s3. *vm-import* is the name of s3 bucket which restores vmware image. * Use this command to monitor the import process. When it shows like this, it means successful. ``` aws ec2 describe-import-image-tasks { "ImportImageTasks": [ { "Status": "completed", "LicenseType": "BYOL", "Description": "OS OVA", "ImageId": "ami-a440a5c4", "Platform": "Linux", "Architecture": "x86_64", "SnapshotDetails": [ { "UserBucket": { "S3Bucket": "vm-import", "S3Key": "os.ova" }, "SnapshotId": "snap-abcd2e33", "DiskImageSize": 974067200.0, "DeviceName": "/dev/sda1", "Format": "VMDK" } ], "ImportTaskId": "import-ami-ffik6b4s" } ] } ```
Pre:
使用Go实现TLS 服务器和客户端
Next:
SMTP using net/mail with STARTTLS
0
likes
416
新浪微博
微信
腾讯微博
QQ空间
人人网
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus
Table of content