Skip to content

enable_image_deprecation

enable_image_deprecation(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    image_id: Optional[ImageId] = None,
    deprecate_at: Optional[MillisecondDateTime] = None,
    dry_run: Optional[Boolean] = None,
) -> EnableImageDeprecationResult

Enables deprecation of the specified AMI at the specified date and time.

For more information, see Deprecate an AMI in the Amazon EC2 User Guide.

Parameters:

  • image_id (Optional[ImageId], default: None ) –

    The ID of the AMI.

  • deprecate_at (Optional[MillisecondDateTime], default: None ) –

    The date and time to deprecate the AMI, in UTC, in the following format: YYYY-MM-DDTHH:MM:SSZ. If you specify a value for seconds, Amazon EC2 rounds the seconds to the nearest minute.

    You can’t specify a date in the past. The upper limit for DeprecateAt is 10 years from now, except for public AMIs, where the upper limit is 2 years from the creation date.

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

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def enable_image_deprecation(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    image_id: Optional["capo_ec2.types.image_id.ImageId"] = None,
    deprecate_at: Optional[
        "capo_ec2.types.millisecond_date_time.MillisecondDateTime"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
) -> "capo_ec2.types.enable_image_deprecation_result.EnableImageDeprecationResult":
    """<p>Enables deprecation of the specified AMI at the specified date and time.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-deprecate.html">Deprecate an AMI</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        image_id: <p>The ID of the AMI.</p>
        deprecate_at: <p>The date and time to deprecate the AMI, in UTC, in the following format: <i>YYYY</i>-<i>MM</i>-<i>DD</i>T<i>HH</i>:<i>MM</i>:<i>SS</i>Z. If you specify a value for seconds, Amazon EC2 rounds the seconds to the nearest minute.</p> <p>You can’t specify a date in the past. The upper limit for <code>DeprecateAt</code> is 10 years from now, except for public AMIs, where the upper limit is 2 years from the creation date.</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>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.enable_image_deprecation_request.EnableImageDeprecationRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.enable_image_deprecation_result.EnableImageDeprecationResult"
    ]:
        import capo_ec2._operations.amazon_ec2.enable_image_deprecation

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("EnableImageDeprecation")
    )
    input_: capo_ec2.types.enable_image_deprecation_request.EnableImageDeprecationRequest = {}
    if image_id is not None:
        input_["image_id"] = image_id
    if deprecate_at is not None:
        input_["deprecate_at"] = deprecate_at
    if dry_run is not None:
        input_["dry_run"] = dry_run

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