Print

Importing the OVA for AMI conversion

Before you begin

Procedure

  1. Open an SSH session.
  2. In Host Name (or IP address), type the IP Address of the virtual server instance, and click Open.
  3. Log in to the Linux server, and run the command: aws.
  4. To configure the AWS details, run the command: aws configure, and do the following:
    1. In AWS Access Key ID, type the AWS access key ID.
    2. In AWS Secret Access Key, type the AWS secret access key ID.
    3. In Default region name, type the region name.

      For example: us-west-2.

    4. In Default output format, type text or json.
  5. To check whether the EC2 instance is ready to use, run the command: aws s3 ls.

    The system displays the S3 bucket that you created.

  6. To view the content of the S3 bucket, run the command: aws s3 ls s3://<nameofbucket>.
  7. To allow importing files into the EC2 instance, create a vmimport role, and associate the following trust policies:
    • AmazonEC2FullAccess

    • IAMFullAccess

    • AmazonS3FullAccess

    • AWSConfigRole

    • AWSOpsWorksInstanceRegistration

    1. Create a file role-policy.json with the following content and run the command: aws iam create-role --role-name vmimport --assume-role-policy-document file://role-policy.json.

      For example:

      {
      "Version":"2012-10-17",
      "Statement":[
      {
      "Effect":"Allow",
      "Action":[
      "s3:ListBucket",
      "s3:GetBucketLocation"
      ],
      "Resource":[
      "arn:aws:s3:::<your_bucket_name>"
      ]
      },
      {
      "Effect":"Allow",
      "Action":[
      "s3:GetObject"
      ],
      "Resource":[
      "arn:aws:s3:::<your_bucket_name>/*"
      ]
      },
      {
      "Effect":"Allow",
      "Action":[
      "ec2:ModifySnapshotAttribute",
      "ec2:CopySnapshot",
      "ec2:RegisterImage",
      "ec2:Describe*"
      ],
      "Resource":"*"
      }
      ]
      }
    2. Create a file called trust-policy.json with the following content and run the command: aws iam create-role --role-name vmimport --assume-role-policy-document file://trust-policy.json.

      For example:

      { "Version":"2012-10-17", "Statement":[ { "Sid":"", "Effect":"Allow", "Principal":{ "Service":"vmie.amazonaws.com" }, "Action":"sts:AssumeRole", "Condition":{ "StringEquals":{ "sts:ExternalId":"vmimport" } } } ] }
  8. To import the ova for conversion, run the command: aws ec2 import-image --cli-input-json "{ \"Description\": \"<Server OVA>\", \"DiskContainers\": [ { \"Description\": \"<text description of task>\", \"UserBucket\": { \"S3Bucket\": \"<your_bucket_name>\", \"S3Key\" : \"<server.ova>\" } } ]}"

    The system displays the Status and the ImportTaskId parameters.

    In the following example, when the system converts the CM Simplex OVA, ImportTaskId is import-ami-ffmanv5x.

    [ec2-user@ip-10-10-11-23 ~]$ aws ec2 import-image --cli-input-json "{ \"Description\": \"CM-Simplex-07.1.0.0.xxx-aws-001.ova\", \"DiskContainers\": [ { \"Description\": \"<First CLI task>\", \"UserBucket\": { \"S3Bucket\": \"avayabucket\", \"S3Key\" : \"CM-Simplex-07.1.0.0.xxx-aws-001.ova\" } } ]}"
    CM-Simplex-07.1.0.0.xxx-aws-001.ova import-ami-ffmanv5x 2 active pending
    SNAPSHOTDETAILS 0.0
    USERBUCKET avayadevbucket CM-Simplex-07.1.0.0.xxx-aws-001.ova
  9. To check the status of the import image, run the command: aws ec2 describe-import-image-tasks --cli-input-json "{ \"ImportTaskIds\": [\"<Your_ImportTaskId>\"], \"NextToken\": \"abc\", \"MaxResults\": 10 } "

    Where, ImportTaskId is the one from the output of the Step 13. For example: import-ami-ffmanv5x.

    The conversion process takes up to 30 minutes. You can run the above command repeatedly. When the AMI conversion is successful, the system displays the Status as completed and also displays ImageId.

    In the following example, the process is at the update stage and is 30% complete.

    [ec2-user@ip-10-143-10-81 ~]$ aws ec2 describe-import-image-tasks --cli-input-json "{ \"ImportTaskIds\": [\"import-ami-ffgji45r\"], \"NextToken\": \"abc\", \"MaxResults\": 10 } " IMPORTIMAGETASKS CM-Simplex-07.1.0.0.xxx-aws-001.ova import-ami-ffgji45r 30 active updating

    In the following example, the process is preparing the AMI and is 76% complete.

     IMPORTIMAGETASKS x86_64 CM-Simplex-07.1.0.0.xxx-aws-001.ova import-ami-ffgji45r BYOL Linux 76 active preparing ami

    The output format varies depending on the selection of the text or JSON format on the aws CLI configuration.

    For more details, see "AWS Import your VM as an image" on the AWS website at http://docs.aws.amazon.com/vm-import/latest/userguide/import-vm-image.html.

  10. Sign in to the Amazon Web Services Management console.
  11. Go to Services > Compute, and click EC2.

    The system displays the EC2 Management Console page.

  12. In the left navigation pane, click IMAGES > AMIs.

    You can search the converted AMI with ImageId. The system displays the newly converted AMI ImageId in the AMI ID column.

    You can give an appropriate name for the AMI ImageId.