Is it possible to convert .img to ami for use with amazon EC2

2

Is there anyway I can launch an instance in amazon using my laptop's image?

Julia_arch

Posted 2016-07-31T19:56:07.483

Reputation: 235

Hello, can you show me how to create a .img files from the Windows system? – The One – 2017-08-07T06:07:49.073

Answers

4

Did you check AWS documentation ? Here is what it says:

  1. Export your your VM from its virtualization environment,
  2. Import/upload the VM file to S3 bucket. Which will be seen here as a file on S3 bucket.
  3. Import Your VM as an Image:

    a- VM Import Service Role

    VM Import requires a role to perform certain operations, such as downloading disk images from an Amazon S3 bucket. You must create a role with the name vmimport with the following policy and trusted entities.

    To create the service role:

    • Create a file named trust-policy.json with the following policy:

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

    • Use the create-role command to create a role named vmimport and give VM Import/Export access to it.

    aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json

    • Create a file named role-policy.json with the following policy, where disk-image-file-bucket is the bucket where the disk images are stored:

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetBucketLocation" ], "Resource": [ "arn:aws:s3:::disk-image-file-bucket" ] }, { "Effect": "Allow", "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::disk-image-file-bucket/*" ] }, { "Effect": "Allow", "Action":[ "ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe*" ], "Resource": "*" } ] }

    • Use the following put-role-policy command to attach the policy to the role created above:

    aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document file://role-policy.json

  4. Import your VM to EC as an image:

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

    Where containers.json file is:

    [ { "Description": "Windows 2008 OVA", "Format": "ova", "UserBucket": { "S3Bucket": "my-import-bucket", "S3Key": "vms/my-windows-2008-vm.ova" } }]

  5. Now you have finished all these steps, you have an AMI ready to be used to launch your instance.

Please check this

Algeriassic

Posted 2016-07-31T19:56:07.483

Reputation: 723

External links can break or be unavailable, in which case your answer would not be useful. Please include the essential information within your answer and use the link for attribution and further reading. Alternatively, you have enough rep to post just a link as a helpful comment. Thanks. – fixer1234 – 2016-08-03T19:31:15.347