- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
ImportVmImageCommand
When you export your virtual machine (VM) from its virtualization environment, that process creates a set of one or more disk container files that act as snapshots of your VM’s environment, settings, and data. The Amazon EC2 API ImportImage action uses those files to import your VM and create an AMI. To import using the CLI command, see import-image
You can reference the task ID from the VM import to pull in the AMI that the import created as the base image for your Image Builder recipe.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { ImagebuilderClient, ImportVmImageCommand } from "@aws-sdk/client-imagebuilder"; // ES Modules import
// const { ImagebuilderClient, ImportVmImageCommand } = require("@aws-sdk/client-imagebuilder"); // CommonJS import
const client = new ImagebuilderClient(config);
const input = { // ImportVmImageRequest
name: "STRING_VALUE", // required
semanticVersion: "STRING_VALUE", // required
description: "STRING_VALUE",
platform: "Windows" || "Linux" || "macOS", // required
osVersion: "STRING_VALUE",
vmImportTaskId: "STRING_VALUE", // required
tags: { // TagMap
"<keys>": "STRING_VALUE",
},
clientToken: "STRING_VALUE", // required
};
const command = new ImportVmImageCommand(input);
const response = await client.send(command);
// { // ImportVmImageResponse
// requestId: "STRING_VALUE",
// imageArn: "STRING_VALUE",
// clientToken: "STRING_VALUE",
// };
ImportVmImageCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
name Required | string | undefined | The name of the base image that is created by the import process. |
platform Required | Platform | undefined | The operating system platform for the imported VM. |
semanticVersion Required | string | undefined | The semantic version to attach to the base image that was created during the import process. This version follows the semantic version syntax. The semantic version has four nodes: Assignment: For the first three nodes you can assign any positive integer value, including zero, with an upper limit of 2^30-1, or 1073741823 for each node. Image Builder automatically assigns the build number to the fourth node. Patterns: You can use any numeric pattern that adheres to the assignment requirements for the nodes that you can assign. For example, you might choose a software version pattern, such as 1.0.0, or a date, such as 2021.01.01. |
vmImportTaskId Required | string | undefined | The |
clientToken | string | undefined | Unique, case-sensitive identifier you provide to ensure idempotency of the request. For more information, see Ensuring idempotency in the Amazon EC2 API Reference. |
description | string | undefined | The description for the base image that is created by the import process. |
osVersion | string | undefined | The operating system version for the imported VM. |
tags | Record<string, string> | undefined | Tags that are attached to the import resources. |
ImportVmImageCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
clientToken | string | undefined | The client token that uniquely identifies the request. |
imageArn | string | undefined | The Amazon Resource Name (ARN) of the AMI that was created during the VM import process. This AMI is used as the base image for the recipe that imported the VM. |
requestId | string | undefined | The request ID that uniquely identifies this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
ClientException | client | These errors are usually caused by a client action, such as using an action or resource on behalf of a user that doesn't have permissions to use the action or resource, or specifying an invalid resource identifier. |
ServiceException | server | This exception is thrown when the service encounters an unrecoverable exception. |
ServiceUnavailableException | server | The service is unable to process your request at this time. |
ImagebuilderServiceException | Base exception class for all service exceptions from Imagebuilder service. |