ImportVmImage
Creates an Image Builder image resource from an Amazon EC2 VM import task. The response
returns as soon as Image Builder creates the image resource in the
PENDING state. Image Builder then monitors the import task
asynchronously. When the task completes, Image Builder records the AMI that it
produced as the new image's output resource and marks the image
AVAILABLE. You can then use the imported image as the base
image for your recipes.
To create the VM import task, use the Amazon EC2 API ImportImage operation, or the import-image AWS CLI command.
Request Syntax
PUT /ImportVmImage HTTP/1.1
Content-type: application/json
{
"clientToken": "string",
"description": "string",
"loggingConfiguration": {
"logGroupName": "string"
},
"name": "string",
"osVersion": "string",
"platform": "string",
"semanticVersion": "string",
"tags": {
"string" : "string"
},
"vmImportTaskId": "string"
}
URI Request Parameters
The request does not use any URI parameters.
Request Body
The request accepts the following data in JSON format.
- clientToken
-
A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see Ensuring idempotency in the Amazon EC2 API Reference.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Required: Yes
- description
-
The description for the base image that is created by the import process.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: No
- loggingConfiguration
-
The CloudWatch Logs log group where Image Builder sends the import logs. For ImportVmImage, the log group name must be within the
/aws/imagebuilder/namespace.Type: ImageLoggingConfiguration object
Required: No
- name
-
The name of the base image that is created by the import process. Image Builder generates the image ARN from a normalized form of the name, so names that differ only in case, spaces, or underscores count as the same name. If an image with the same name and semantic version already exists in your account in the same AWS Region, the import creates a new build version for it.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: Yes
- osVersion
-
The operating system version for the imported VM.
Type: String
Length Constraints: Minimum length of 1.
Required: No
- platform
-
The operating system platform for the imported VM.
Type: String
Valid Values:
Windows | Linux | macOSRequired: Yes
- semanticVersion
-
The semantic version to attach to the base image that was created during the import process. This version follows the semantic version syntax.
Note
The semantic version has four nodes: <major>.<minor>.<patch>/<build>. You can assign values for the first three, and can filter on all of them.
Assignment: For the first three nodes, you can assign any positive integer value, including zero. The upper limit is 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.
Type: String
Pattern:
^[0-9]+\.[0-9]+\.[0-9]+$Required: Yes
-
Tags that are attached to the import resources.
Type: String to string map
Map Entries: Maximum number of 50 items.
Key Length Constraints: Minimum length of 1. Maximum length of 128.
Key Pattern:
^(?!aws:)[a-zA-Z0-9\s_.:/=+\-@]*$Value Length Constraints: Maximum length of 256.
Required: No
- vmImportTaskId
-
The
importTaskId(API) orImportTaskId(AWS CLI) from the Amazon EC2 VM import process. The import task doesn't need to be complete when you call ImportVmImage - Image Builder monitors the task and finishes creating the image when the task completes.Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: Yes
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"clientToken": "string",
"imageArn": "string",
"requestId": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- clientToken
-
The client token that uniquely identifies the request.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
- imageArn
-
The Amazon Resource Name (ARN) of the Image Builder image resource that this request created. Image Builder records the AMI from the VM import task in the image's output resources after the task completes.
Type: String
- requestId
-
The request ID that uniquely identifies this request.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Errors
For information about the errors that are common to all actions, see Common Error Types.
- ClientException
-
A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.
HTTP Status Code: 400
- ServiceException
-
An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.
HTTP Status Code: 500
- ServiceUnavailableException
-
The service is unable to process your request at this time.
HTTP Status Code: 503
Examples
Import a virtual machine as an Image Builder image
The following example registers the output of an EC2 VM Import/Export task (import-ami) as a new Image Builder image, so you can use the imported virtual machine as a base image.
Sample Request
PUT /ImportVmImage HTTP/1.1
Content-type: application/json
{
"name": "my-example-imported-image",
"semanticVersion": "1.0.0",
"platform": "Linux",
"osVersion": "Amazon Linux 2",
"vmImportTaskId": "import-ami-1234567890abcdef0",
"clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE00000"
}
Sample Response
HTTP/1.1 200
Content-type: application/json
{
"requestId": "f8a1d0ce-42b7-4d6a-9b12-3c84a02e5f19",
"clientToken": "a1b2c3d4-5678-90ab-cdef-EXAMPLE00000",
"imageArn": "arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-imported-image/1.0.0/1"
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: