Skip to content

import_disk_image

import_disk_image(
    name: ResourceName,
    semantic_version: VersionNumber,
    platform: NonEmptyString,
    os_version: OsVersion,
    infrastructure_configuration_arn: InfrastructureConfigurationArn,
    uri: Uri,
    client_token: ClientToken,
    *,
    config_overrides: Optional[imagebuilderClientConfig] = None,
    description: Optional[NonEmptyString] = None,
    execution_role: Optional[RoleNameOrArn] = None,
    logging_configuration: Optional[ImageLoggingConfiguration] = None,
    tags: Optional[TagMap] = None,
    register_image_options: Optional[RegisterImageOptions] = None,
    windows_configuration: Optional[WindowsConfiguration] = None,
) -> ImportDiskImageResponse

Imports a Windows operating system image from a verified Microsoft ISO disk file. The following disk images are supported:

  • Windows 11 Enterprise

The response returns as soon as Image Builder creates the new image resource in the PENDING state. The conversion from ISO file to AMI then runs asynchronously on an EC2 instance that Image Builder launches with the specified infrastructure configuration.

Parameters:

  • name (ResourceName) –

    The name of the image resource that's created from the import. 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 Amazon Web Services Region, the import creates a new build version for it.

  • semantic_version (VersionNumber) –

    The semantic version to attach to the image that's created during the import process. This version follows the semantic version syntax.

  • description (Optional[NonEmptyString], default: None ) –

    The description for your disk image import.

  • platform (NonEmptyString) –

    The operating system platform for the imported image. Allowed values include the following: Windows.

  • os_version (OsVersion) –

    The operating system version for the imported image. The only supported value is Microsoft Windows 11.

  • execution_role (Optional[RoleNameOrArn], default: None ) –

    The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to perform workflow actions to import an image from a Microsoft ISO file. If you don't provide a role, Image Builder uses the Image Builder service-linked role in your account, and creates it if it doesn't exist.

  • infrastructure_configuration_arn (InfrastructureConfigurationArn) –

    The Amazon Resource Name (ARN) of the infrastructure configuration resource that's used for launching the EC2 instance on which the ISO image is built.

  • uri (Uri) –

    The uri of the ISO disk file that's stored in Amazon S3, in s3://bucket/key format. The key must end with the .iso, .ISO, or .Iso extension, and the bucket must be owned by the account that makes the request.

  • logging_configuration (Optional[ImageLoggingConfiguration], default: None ) –

    The CloudWatch Logs log group where Image Builder sends the import logs. If you specify a log group name outside of the /aws/imagebuilder/ namespace, you must also provide an executionRole that has permission to write to that log group.

  • tags (Optional[TagMap], default: None ) –

    Tags that are attached to image resources created from the import.

  • register_image_options (Optional[RegisterImageOptions], default: None ) –

    Configures Secure Boot and UEFI settings for the imported image.

  • windows_configuration (Optional[WindowsConfiguration], default: None ) –

    Specifies Windows settings for ISO imports.

  • client_token (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.

Raises:

  • AccessDeniedException –

    You do not have permissions to perform the requested operation.

  • 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.

  • ServiceException –

    An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.

  • ServiceUnavailableException –

    The service is unable to process your request at this time.

  • TooManyRequestsException –

    You have attempted too many requests for the specific operation.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Import a Windows 11 ISO disk image The following example starts an image build that converts a Windows 11 ISO disk file stored in Amazon S3 into an AMI; the imageBuildVersionArn in the response identifies the Image Builder image resource that tracks the build, not the output AMI.

>>> client.import_disk_image(name='my-example-imported-image', semantic_version='1.0.0', platform='Windows', os_version='Microsoft Windows 11', uri='s3://amzn-s3-demo-bucket/Win11_23H2_English_x64.iso', infrastructure_configuration_arn='arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/my-example-infrastructure', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE12345')
Source code in docs_src/capo_imagebuilder/_services/imagebuilder.py
def import_disk_image(
    self,
    name: "capo_imagebuilder.types.resource_name.ResourceName",
    semantic_version: "capo_imagebuilder.types.version_number.VersionNumber",
    platform: "capo_imagebuilder.types.non_empty_string.NonEmptyString",
    os_version: "capo_imagebuilder.types.os_version.OsVersion",
    infrastructure_configuration_arn: "capo_imagebuilder.types.infrastructure_configuration_arn.InfrastructureConfigurationArn",
    uri: "capo_imagebuilder.types.uri.Uri",
    client_token: "capo_imagebuilder.types.client_token.ClientToken",
    *,
    config_overrides: Optional[imagebuilderClientConfig] = None,
    description: Optional[
        "capo_imagebuilder.types.non_empty_string.NonEmptyString"
    ] = None,
    execution_role: Optional[
        "capo_imagebuilder.types.role_name_or_arn.RoleNameOrArn"
    ] = None,
    logging_configuration: Optional[
        "capo_imagebuilder.types.image_logging_configuration.ImageLoggingConfiguration"
    ] = None,
    tags: Optional["capo_imagebuilder.types.tag_map.TagMap"] = None,
    register_image_options: Optional[
        "capo_imagebuilder.types.register_image_options.RegisterImageOptions"
    ] = None,
    windows_configuration: Optional[
        "capo_imagebuilder.types.windows_configuration.WindowsConfiguration"
    ] = None,
) -> "capo_imagebuilder.types.import_disk_image_response.ImportDiskImageResponse":
    """<p>Imports a Windows operating system image from a verified Microsoft ISO disk file. The following disk images are supported:</p> <ul> <li> <p>Windows 11 Enterprise</p> </li> </ul> <p>The response returns as soon as Image Builder creates the new image resource in the <code>PENDING</code> state. The conversion from ISO file to AMI then runs asynchronously on an EC2 instance that Image Builder launches with the specified infrastructure configuration.</p>

    Args:
        name: <p>The name of the image resource that's created from the import. 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 Amazon Web Services Region, the import creates a new build version for it.</p>
        semantic_version: <p>The semantic version to attach to the image that's created during the import process. This version follows the semantic version syntax.</p>
        description: <p>The description for your disk image import.</p>
        platform: <p>The operating system platform for the imported image. Allowed values include the following: <code>Windows</code>.</p>
        os_version: <p>The operating system version for the imported image. The only supported value is <code>Microsoft Windows 11</code>.</p>
        execution_role: <p>The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to perform workflow actions to import an image from a Microsoft ISO file. If you don't provide a role, Image Builder uses the Image Builder service-linked role in your account, and creates it if it doesn't exist.</p>
        infrastructure_configuration_arn: <p>The Amazon Resource Name (ARN) of the infrastructure configuration resource that's used for launching the EC2 instance on which the ISO image is built.</p>
        uri: <p>The <code>uri</code> of the ISO disk file that's stored in Amazon S3, in <code>s3://bucket/key</code> format. The key must end with the <code>.iso</code>, <code>.ISO</code>, or <code>.Iso</code> extension, and the bucket must be owned by the account that makes the request.</p>
        logging_configuration: <p>The CloudWatch Logs log group where Image Builder sends the import logs. If you specify a log group name outside of the <code>/aws/imagebuilder/</code> namespace, you must also provide an <code>executionRole</code> that has permission to write to that log group.</p>
        tags: <p>Tags that are attached to image resources created from the import.</p>
        register_image_options: <p>Configures Secure Boot and UEFI settings for the imported image.</p>
        windows_configuration: <p>Specifies Windows settings for ISO imports.</p>
        client_token: <p>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 <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a> in the <i>Amazon EC2 API Reference</i>.</p>

    Raises:
        capo_imagebuilder.errors.access_denied_exception.AccessDeniedException: <p>You do not have permissions to perform the requested operation.</p>
        capo_imagebuilder.errors.client_exception.ClientException: <p>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.</p>
        capo_imagebuilder.errors.service_exception.ServiceException: <p>An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.</p>
        capo_imagebuilder.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unable to process your request at this time.</p>
        capo_imagebuilder.errors.too_many_requests_exception.TooManyRequestsException: <p>You have attempted too many requests for the specific operation.</p>
        capo_imagebuilder.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Import a Windows 11 ISO disk image
        The following example starts an image build that converts a Windows 11 ISO disk file stored in Amazon S3 into an AMI; the imageBuildVersionArn in the response identifies the Image Builder image resource that tracks the build, not the output AMI.

        >>> client.import_disk_image(name='my-example-imported-image', semantic_version='1.0.0', platform='Windows', os_version='Microsoft Windows 11', uri='s3://amzn-s3-demo-bucket/Win11_23H2_English_x64.iso', infrastructure_configuration_arn='arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/my-example-infrastructure', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE12345')
    """

    def _handler(
        req: "OperationRequest[capo_imagebuilder.types.import_disk_image_request.ImportDiskImageRequest]",
    ) -> OperationResponse[
        "capo_imagebuilder.types.import_disk_image_response.ImportDiskImageResponse"
    ]:
        import capo_imagebuilder._operations.imagebuilder.import_disk_image

        output, http_response = (
            capo_imagebuilder._operations.imagebuilder.import_disk_image.import_disk_image(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ImportDiskImage")
    )
    input_: capo_imagebuilder.types.import_disk_image_request.ImportDiskImageRequest = {
        "name": name,
        "semantic_version": semantic_version,
        "platform": platform,
        "os_version": os_version,
        "infrastructure_configuration_arn": infrastructure_configuration_arn,
        "uri": uri,
        "client_token": client_token,
    }
    if description is not None:
        input_["description"] = description
    if execution_role is not None:
        input_["execution_role"] = execution_role
    if logging_configuration is not None:
        input_["logging_configuration"] = logging_configuration
    if tags is not None:
        input_["tags"] = tags
    if register_image_options is not None:
        input_["register_image_options"] = register_image_options
    if windows_configuration is not None:
        input_["windows_configuration"] = windows_configuration

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output