Skip to content

register_image

register_image(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    image_location: Optional[String] = None,
    billing_products: Optional[BillingProductList] = None,
    boot_mode: Optional[BootModeValues] = None,
    tpm_support: Optional[TpmSupportValues] = None,
    uefi_data: Optional[ImageUefiDataRequest] = None,
    imds_support: Optional[ImdsSupportValues] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    dry_run: Optional[Boolean] = None,
    name: Optional[ImageNameRequest] = None,
    description: Optional[ImageDescriptionRequest] = None,
    architecture: Optional[ArchitectureValues] = None,
    kernel_id: Optional[KernelId] = None,
    ramdisk_id: Optional[RamdiskId] = None,
    root_device_name: Optional[String] = None,
    block_device_mappings: Optional[BlockDeviceMappingRequestList] = None,
    virtualization_type: Optional[String] = None,
    sriov_net_support: Optional[String] = None,
    ena_support: Optional[Boolean] = None,
) -> RegisterImageResult

Registers an AMI. When you're creating an instance-store backed AMI, registering the AMI is the final step in the creation process. For more information about creating AMIs, see Create an AMI from a snapshot and Create an instance-store backed AMI in the Amazon EC2 User Guide.

If needed, you can deregister an AMI at any time. Any modifications you make to an AMI backed by an instance store volume invalidates its registration. If you make changes to an image, deregister the previous image and register the new image.

Register a snapshot of a root device volume

You can use RegisterImage to create an Amazon EBS-backed Linux AMI from a snapshot of a root device volume. You specify the snapshot using a block device mapping. You can't set the encryption state of the volume using the block device mapping. If the snapshot is encrypted, or encryption by default is enabled, the root volume of an instance launched from the AMI is encrypted.

For more information, see Create an AMI from a snapshot and Use encryption with EBS-backed AMIs in the Amazon EC2 User Guide.

Amazon Web Services Marketplace product codes

If any snapshots have Amazon Web Services Marketplace product codes, they are copied to the new AMI.

In most cases, AMIs for Windows, RedHat, SUSE, and SQL Server require correct licensing information to be present on the AMI. For more information, see Understand AMI billing information in the Amazon EC2 User Guide. When creating an AMI from a snapshot, the RegisterImage operation derives the correct billing information from the snapshot's metadata, but this requires the appropriate metadata to be present. To verify if the correct billing information was applied, check the PlatformDetails field on the new AMI. If the field is empty or doesn't match the expected operating system code (for example, Windows, RedHat, SUSE, or SQL), the AMI creation was unsuccessful, and you should discard the AMI and instead create the AMI from an instance. For more information, see Create an AMI from an instance in the Amazon EC2 User Guide.

If you purchase a Reserved Instance to apply to an On-Demand Instance that was launched from an AMI with a billing product code, make sure that the Reserved Instance has the matching billing product code. If you purchase a Reserved Instance without the matching billing product code, the Reserved Instance is not applied to the On-Demand Instance. For information about how to obtain the platform details and billing information of an AMI, see Understand AMI billing information in the Amazon EC2 User Guide.

Parameters:

  • image_location (Optional[String], default: None ) –

    The full path to your AMI manifest in Amazon S3 storage. The specified bucket must have the aws-exec-read canned access control list (ACL) to ensure that it can be accessed by Amazon EC2. For more information, see Canned ACL in the Amazon S3 Service Developer Guide.

  • billing_products (Optional[BillingProductList], default: None ) –

    The billing product codes. Your account must be authorized to specify billing product codes.

    If your account is not authorized to specify billing product codes, you can publish AMIs that include billable software and list them on the Amazon Web Services Marketplace. You must first register as a seller on the Amazon Web Services Marketplace. For more information, see Getting started as an Amazon Web Services Marketplace seller and AMI-based products in Amazon Web Services Marketplace in the Amazon Web Services Marketplace Seller Guide.

  • boot_mode (Optional[BootModeValues], default: None ) –

    The boot mode of the AMI. A value of uefi-preferred indicates that the AMI supports both UEFI and Legacy BIOS.

    The operating system contained in the AMI must be configured to support the specified boot mode.

    For more information, see Instance launch behavior with Amazon EC2 boot modes in the Amazon EC2 User Guide.

  • tpm_support (Optional[TpmSupportValues], default: None ) –

    Set to v2.0 to enable Trusted Platform Module (TPM) support. For more information, see NitroTPM in the Amazon EC2 User Guide.

  • uefi_data (Optional[ImageUefiDataRequest], default: None ) –

    Base64 representation of the non-volatile UEFI variable store. To retrieve the UEFI data, use the GetInstanceUefiData command. You can inspect and modify the UEFI data by using the python-uefivars tool on GitHub. For more information, see UEFI Secure Boot for Amazon EC2 instances in the Amazon EC2 User Guide.

  • imds_support (Optional[ImdsSupportValues], default: None ) –

    Set to v2.0 to indicate that IMDSv2 is specified in the AMI. Instances launched from this AMI will have HttpTokens automatically set to required so that, by default, the instance requires that IMDSv2 is used when requesting instance metadata. In addition, HttpPutResponseHopLimit is set to 2. For more information, see Configure the AMI in the Amazon EC2 User Guide.

    If you set the value to v2.0, make sure that your AMI software can support IMDSv2.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to apply to the AMI.

    To tag the AMI, the value for ResourceType must be image. If you specify another value for ResourceType, the request fails.

    To tag an AMI after it has been registered, see CreateTags.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • name (Optional[ImageNameRequest], default: None ) –

    A name for your AMI.

    Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)

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

    A description for your AMI.

  • architecture (Optional[ArchitectureValues], default: None ) –

    The architecture of the AMI.

    Default: For Amazon EBS-backed AMIs, i386. For instance store-backed AMIs, the architecture specified in the manifest file.

  • kernel_id (Optional[KernelId], default: None ) –

    The ID of the kernel.

  • ramdisk_id (Optional[RamdiskId], default: None ) –

    The ID of the RAM disk.

  • root_device_name (Optional[String], default: None ) –

    The device name of the root device volume (for example, /dev/sda1).

  • block_device_mappings (Optional[BlockDeviceMappingRequestList], default: None ) –

    The block device mapping entries.

    If you specify an Amazon EBS volume using the ID of an Amazon EBS snapshot, you can't specify the encryption state of the volume.

    If you create an AMI on an Outpost, then all backing snapshots must be on the same Outpost or in the Region of that Outpost. AMIs on an Outpost that include local snapshots can be used to launch instances on the same Outpost only. For more information, Create AMIs from local snapshots in the Amazon EBS User Guide.

  • virtualization_type (Optional[String], default: None ) –

    The type of virtualization (hvm | paravirtual).

    Default: paravirtual

  • sriov_net_support (Optional[String], default: None ) –

    Set to simple to enable enhanced networking with the Intel 82599 Virtual Function interface for the AMI and any instances that you launch from the AMI.

    There is no way to disable sriovNetSupport at this time.

    This option is supported only for HVM AMIs. Specifying this option with a PV AMI can make instances launched from the AMI unreachable.

  • ena_support (Optional[Boolean], default: None ) –

    Set to true to enable enhanced networking with ENA for the AMI and any instances that you launch from the AMI.

    This option is supported only for HVM AMIs. Specifying this option with a PV AMI can make instances launched from the AMI unreachable.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def register_image(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    image_location: Optional["capo_ec2.types.string.String"] = None,
    billing_products: Optional[
        "capo_ec2.types.billing_product_list.BillingProductList"
    ] = None,
    boot_mode: Optional["capo_ec2.types.boot_mode_values.BootModeValues"] = None,
    tpm_support: Optional[
        "capo_ec2.types.tpm_support_values.TpmSupportValues"
    ] = None,
    uefi_data: Optional[
        "capo_ec2.types.image_uefi_data_request.ImageUefiDataRequest"
    ] = None,
    imds_support: Optional[
        "capo_ec2.types.imds_support_values.ImdsSupportValues"
    ] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    name: Optional["capo_ec2.types.image_name_request.ImageNameRequest"] = None,
    description: Optional[
        "capo_ec2.types.image_description_request.ImageDescriptionRequest"
    ] = None,
    architecture: Optional[
        "capo_ec2.types.architecture_values.ArchitectureValues"
    ] = None,
    kernel_id: Optional["capo_ec2.types.kernel_id.KernelId"] = None,
    ramdisk_id: Optional["capo_ec2.types.ramdisk_id.RamdiskId"] = None,
    root_device_name: Optional["capo_ec2.types.string.String"] = None,
    block_device_mappings: Optional[
        "capo_ec2.types.block_device_mapping_request_list.BlockDeviceMappingRequestList"
    ] = None,
    virtualization_type: Optional["capo_ec2.types.string.String"] = None,
    sriov_net_support: Optional["capo_ec2.types.string.String"] = None,
    ena_support: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.register_image_result.RegisterImageResult":
    """<p>Registers an AMI. When you're creating an instance-store backed AMI, registering the AMI is the final step in the creation process. For more information about creating AMIs, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html#creating-launching-ami-from-snapshot">Create an AMI from a snapshot</a> and <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-instance-store.html">Create an instance-store backed AMI</a> in the <i>Amazon EC2 User Guide</i>.</p> <p>If needed, you can deregister an AMI at any time. Any modifications you make to an AMI backed by an instance store volume invalidates its registration. If you make changes to an image, deregister the previous image and register the new image.</p> <p> <b>Register a snapshot of a root device volume</b> </p> <p>You can use <code>RegisterImage</code> to create an Amazon EBS-backed Linux AMI from a snapshot of a root device volume. You specify the snapshot using a block device mapping. You can't set the encryption state of the volume using the block device mapping. If the snapshot is encrypted, or encryption by default is enabled, the root volume of an instance launched from the AMI is encrypted.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html#creating-launching-ami-from-snapshot">Create an AMI from a snapshot</a> and <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIEncryption.html">Use encryption with EBS-backed AMIs</a> in the <i>Amazon EC2 User Guide</i>.</p> <p> <b>Amazon Web Services Marketplace product codes</b> </p> <p>If any snapshots have Amazon Web Services Marketplace product codes, they are copied to the new AMI.</p> <p>In most cases, AMIs for Windows, RedHat, SUSE, and SQL Server require correct licensing information to be present on the AMI. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-billing-info.html">Understand AMI billing information</a> in the <i>Amazon EC2 User Guide</i>. When creating an AMI from a snapshot, the <code>RegisterImage</code> operation derives the correct billing information from the snapshot's metadata, but this requires the appropriate metadata to be present. To verify if the correct billing information was applied, check the <code>PlatformDetails</code> field on the new AMI. If the field is empty or doesn't match the expected operating system code (for example, Windows, RedHat, SUSE, or SQL), the AMI creation was unsuccessful, and you should discard the AMI and instead create the AMI from an instance. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html#how-to-create-ebs-ami">Create an AMI from an instance </a> in the <i>Amazon EC2 User Guide</i>.</p> <p>If you purchase a Reserved Instance to apply to an On-Demand Instance that was launched from an AMI with a billing product code, make sure that the Reserved Instance has the matching billing product code. If you purchase a Reserved Instance without the matching billing product code, the Reserved Instance is not applied to the On-Demand Instance. For information about how to obtain the platform details and billing information of an AMI, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-billing-info.html">Understand AMI billing information</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        image_location: <p>The full path to your AMI manifest in Amazon S3 storage. The specified bucket must have the <code>aws-exec-read</code> canned access control list (ACL) to ensure that it can be accessed by Amazon EC2. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl">Canned ACL</a> in the <i>Amazon S3 Service Developer Guide</i>.</p>
        billing_products: <p>The billing product codes. Your account must be authorized to specify billing product codes.</p> <p>If your account is not authorized to specify billing product codes, you can publish AMIs that include billable software and list them on the Amazon Web Services Marketplace. You must first register as a seller on the Amazon Web Services Marketplace. For more information, see <a href="https://docs.aws.amazon.com/marketplace/latest/userguide/user-guide-for-sellers.html">Getting started as an Amazon Web Services Marketplace seller</a> and <a href="https://docs.aws.amazon.com/marketplace/latest/userguide/ami-products.html">AMI-based products in Amazon Web Services Marketplace</a> in the <i>Amazon Web Services Marketplace Seller Guide</i>.</p>
        boot_mode: <p>The boot mode of the AMI. A value of <code>uefi-preferred</code> indicates that the AMI supports both UEFI and Legacy BIOS.</p> <note> <p>The operating system contained in the AMI must be configured to support the specified boot mode.</p> </note> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-boot.html">Instance launch behavior with Amazon EC2 boot modes</a> in the <i>Amazon EC2 User Guide</i>.</p>
        tpm_support: <p>Set to <code>v2.0</code> to enable Trusted Platform Module (TPM) support. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nitrotpm.html">NitroTPM</a> in the <i>Amazon EC2 User Guide</i>.</p>
        uefi_data: <p>Base64 representation of the non-volatile UEFI variable store. To retrieve the UEFI data, use the <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_GetInstanceUefiData">GetInstanceUefiData</a> command. You can inspect and modify the UEFI data by using the <a href="https://github.com/awslabs/python-uefivars">python-uefivars tool</a> on GitHub. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/uefi-secure-boot.html">UEFI Secure Boot for Amazon EC2 instances</a> in the <i>Amazon EC2 User Guide</i>.</p>
        imds_support: <p>Set to <code>v2.0</code> to indicate that IMDSv2 is specified in the AMI. Instances launched from this AMI will have <code>HttpTokens</code> automatically set to <code>required</code> so that, by default, the instance requires that IMDSv2 is used when requesting instance metadata. In addition, <code>HttpPutResponseHopLimit</code> is set to <code>2</code>. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-IMDS-new-instances.html#configure-IMDS-new-instances-ami-configuration">Configure the AMI</a> in the <i>Amazon EC2 User Guide</i>.</p> <note> <p>If you set the value to <code>v2.0</code>, make sure that your AMI software can support IMDSv2.</p> </note>
        tag_specifications: <p>The tags to apply to the AMI.</p> <p>To tag the AMI, the value for <code>ResourceType</code> must be <code>image</code>. If you specify another value for <code>ResourceType</code>, the request fails.</p> <p>To tag an AMI after it has been registered, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateTags.html">CreateTags</a>.</p>
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        name: <p>A name for your AMI.</p> <p>Constraints: 3-128 alphanumeric characters, parentheses (()), square brackets ([]), spaces ( ), periods (.), slashes (/), dashes (-), single quotes ('), at-signs (@), or underscores(_)</p>
        description: <p>A description for your AMI.</p>
        architecture: <p>The architecture of the AMI.</p> <p>Default: For Amazon EBS-backed AMIs, <code>i386</code>. For instance store-backed AMIs, the architecture specified in the manifest file.</p>
        kernel_id: <p>The ID of the kernel.</p>
        ramdisk_id: <p>The ID of the RAM disk.</p>
        root_device_name: <p>The device name of the root device volume (for example, <code>/dev/sda1</code>).</p>
        block_device_mappings: <p>The block device mapping entries.</p> <p>If you specify an Amazon EBS volume using the ID of an Amazon EBS snapshot, you can't specify the encryption state of the volume.</p> <p>If you create an AMI on an Outpost, then all backing snapshots must be on the same Outpost or in the Region of that Outpost. AMIs on an Outpost that include local snapshots can be used to launch instances on the same Outpost only. For more information, <a href="https://docs.aws.amazon.com/ebs/latest/userguide/snapshots-outposts.html#ami">Create AMIs from local snapshots</a> in the <i>Amazon EBS User Guide</i>.</p>
        virtualization_type: <p>The type of virtualization (<code>hvm</code> | <code>paravirtual</code>).</p> <p>Default: <code>paravirtual</code> </p>
        sriov_net_support: <p>Set to <code>simple</code> to enable enhanced networking with the Intel 82599 Virtual Function interface for the AMI and any instances that you launch from the AMI.</p> <p>There is no way to disable <code>sriovNetSupport</code> at this time.</p> <p>This option is supported only for HVM AMIs. Specifying this option with a PV AMI can make instances launched from the AMI unreachable.</p>
        ena_support: <p>Set to <code>true</code> to enable enhanced networking with ENA for the AMI and any instances that you launch from the AMI.</p> <p>This option is supported only for HVM AMIs. Specifying this option with a PV AMI can make instances launched from the AMI unreachable.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.register_image_request.RegisterImageRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.register_image_result.RegisterImageResult"
    ]:
        import capo_ec2._operations.amazon_ec2.register_image

        output, http_response = (
            capo_ec2._operations.amazon_ec2.register_image.register_image(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_ec2.types.register_image_request.RegisterImageRequest",
    ) -> dict[str, Any]:
        import capo_ec2.types.register_image_request

        return capo_ec2.types.register_image_request.redact_sensitive(input_)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("RegisterImage", redact_input=_redact_input),
    )
    input_: capo_ec2.types.register_image_request.RegisterImageRequest = {}
    if image_location is not None:
        input_["image_location"] = image_location
    if billing_products is not None:
        input_["billing_products"] = billing_products
    if boot_mode is not None:
        input_["boot_mode"] = boot_mode
    if tpm_support is not None:
        input_["tpm_support"] = tpm_support
    if uefi_data is not None:
        input_["uefi_data"] = uefi_data
    if imds_support is not None:
        input_["imds_support"] = imds_support
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if name is not None:
        input_["name"] = name
    if description is not None:
        input_["description"] = description
    if architecture is not None:
        input_["architecture"] = architecture
    if kernel_id is not None:
        input_["kernel_id"] = kernel_id
    if ramdisk_id is not None:
        input_["ramdisk_id"] = ramdisk_id
    if root_device_name is not None:
        input_["root_device_name"] = root_device_name
    if block_device_mappings is not None:
        input_["block_device_mappings"] = block_device_mappings
    if virtualization_type is not None:
        input_["virtualization_type"] = virtualization_type
    if sriov_net_support is not None:
        input_["sriov_net_support"] = sriov_net_support
    if ena_support is not None:
        input_["ena_support"] = ena_support

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