Skip to content

start_resource_state_update async

start_resource_state_update(
    resource_arn: ImageBuildVersionArn,
    state: ResourceState,
    client_token: ClientToken,
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
    execution_role: Optional[RoleNameOrArn] = None,
    include_resources: Optional[ResourceStateUpdateIncludeResources] = None,
    exclusion_rules: Optional[ResourceStateUpdateExclusionRules] = None,
    update_at: Optional[DateTimeTimestamp] = None,
) -> StartResourceStateUpdateResponse

Begins an ad-hoc state change for the specified image build version. This is a one-time operation - if you schedule the update, it runs only once. If the request includes underlying resources, or schedules the update far enough in the future, Image Builder runs the update as an asynchronous lifecycle execution and returns its identifier. Otherwise, for target states other than DELETED, the state change applies immediately. If a request that starts a lifecycle execution arrives while the image already has one in progress, Image Builder rejects it.

Parameters:

  • resource_arn (ImageBuildVersionArn) –

    The Amazon Resource Name (ARN) of the image build version to update. The image must be in one of these terminal states: AVAILABLE, DEPRECATED, DISABLED, FAILED, or CANCELLED. Images with FAILED or CANCELLED status can transition only to DELETED.

  • state (ResourceState) –

    Specifies the lifecycle action to take for this request. For AMI-based images, valid values are AVAILABLE, DEPRECATED, DISABLED, and DELETED. For container-based images, only DELETED is supported.

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

    The name or Amazon Resource Name (ARN) of the IAM role that's used to update image state. You must provide this property together with includeResources. Neither is valid without the other.

  • include_resources (Optional[ResourceStateUpdateIncludeResources], default: None ) –

    Specifies which underlying resources to update, in addition to the Image Builder image resource itself. Snapshots and containers are only valid for the DELETED state. To set an image to DELETED, you must include its underlying resources. To delete only the Image Builder image record, use the DeleteImage operation instead.

  • exclusion_rules (Optional[ResourceStateUpdateExclusionRules], default: None ) –

    Rules that Image Builder evaluates against each of the image's AMIs. Matching AMIs and their snapshots are skipped. Exclusion rules only take effect when the request includes AMIs. If the target state is DELETED and any resource was skipped, the Image Builder image resource itself is also retained. For the DEPRECATED and DISABLED target states, Image Builder updates the image resource's state regardless of exclusions.

  • update_at (Optional[DateTimeTimestamp], default: None ) –

    The timestamp that indicates when resources are updated by a lifecycle action. This property is valid only when the target status is DEPRECATED, and the value must be a future time. If you don't specify a value, Image Builder begins the state update right away. For a scheduled deprecation, included AMIs get their EC2 deprecation time set immediately, and Image Builder schedules the image resource to transition to DEPRECATED at that time.

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

  • CallRateLimitExceededException –

    You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.

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

  • ForbiddenException –

    You are not authorized to perform the requested operation.

  • IdempotentParameterMismatchException –

    You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.

  • InvalidRequestException –

    The request is malformed or otherwise invalid. Verify the request and try again.

  • ResourceInUseException –

    The resource that you are trying to operate on is currently in use. Review the message details and retry later.

  • ResourceNotFoundException –

    At least one of the resources referenced by your request does not exist.

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

  • UnknownServiceError –

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

Examples:

Schedule an image build version for deprecation The following example schedules the specified image build version and its AMI to move to the DEPRECATED state at the requested future time. It returns the ID of the lifecycle execution that applies the update.

>>> await client.start_resource_state_update(resource_arn='arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-recipe/1.0.0/1', state={'status': 'DEPRECATED'}, execution_role='arn:aws:iam::111122223333:role/my-example-state-update-role', include_resources={'amis': True}, update_at='2026-09-11T21:20:00Z', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE24680')
Source code in docs_src/capo_imagebuilder/_services/async_imagebuilder.py
async def start_resource_state_update(
    self,
    resource_arn: "capo_imagebuilder.types.image_build_version_arn.ImageBuildVersionArn",
    state: "capo_imagebuilder.types.resource_state.ResourceState",
    client_token: "capo_imagebuilder.types.client_token.ClientToken",
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
    execution_role: Optional[
        "capo_imagebuilder.types.role_name_or_arn.RoleNameOrArn"
    ] = None,
    include_resources: Optional[
        "capo_imagebuilder.types.resource_state_update_include_resources.ResourceStateUpdateIncludeResources"
    ] = None,
    exclusion_rules: Optional[
        "capo_imagebuilder.types.resource_state_update_exclusion_rules.ResourceStateUpdateExclusionRules"
    ] = None,
    update_at: Optional[
        "capo_imagebuilder.types.date_time_timestamp.DateTimeTimestamp"
    ] = None,
) -> "capo_imagebuilder.types.start_resource_state_update_response.StartResourceStateUpdateResponse":
    """<p>Begins an ad-hoc state change for the specified image build version. This is a one-time operation - if you schedule the update, it runs only once. If the request includes underlying resources, or schedules the update far enough in the future, Image Builder runs the update as an asynchronous lifecycle execution and returns its identifier. Otherwise, for target states other than <code>DELETED</code>, the state change applies immediately. If a request that starts a lifecycle execution arrives while the image already has one in progress, Image Builder rejects it.</p>

    Args:
        resource_arn: <p>The Amazon Resource Name (ARN) of the image build version to update. The image must be in one of these terminal states: <code>AVAILABLE</code>, <code>DEPRECATED</code>, <code>DISABLED</code>, <code>FAILED</code>, or <code>CANCELLED</code>. Images with <code>FAILED</code> or <code>CANCELLED</code> status can transition only to <code>DELETED</code>.</p>
        state: <p>Specifies the lifecycle action to take for this request. For AMI-based images, valid values are <code>AVAILABLE</code>, <code>DEPRECATED</code>, <code>DISABLED</code>, and <code>DELETED</code>. For container-based images, only <code>DELETED</code> is supported.</p>
        execution_role: <p>The name or Amazon Resource Name (ARN) of the IAM role that's used to update image state. You must provide this property together with <code>includeResources</code>. Neither is valid without the other.</p>
        include_resources: <p>Specifies which underlying resources to update, in addition to the Image Builder image resource itself. Snapshots and containers are only valid for the <code>DELETED</code> state. To set an image to <code>DELETED</code>, you must include its underlying resources. To delete only the Image Builder image record, use the <a>DeleteImage</a> operation instead.</p>
        exclusion_rules: <p>Rules that Image Builder evaluates against each of the image's AMIs. Matching AMIs and their snapshots are skipped. Exclusion rules only take effect when the request includes AMIs. If the target state is <code>DELETED</code> and any resource was skipped, the Image Builder image resource itself is also retained. For the <code>DEPRECATED</code> and <code>DISABLED</code> target states, Image Builder updates the image resource's state regardless of exclusions.</p>
        update_at: <p>The timestamp that indicates when resources are updated by a lifecycle action. This property is valid only when the target status is <code>DEPRECATED</code>, and the value must be a future time. If you don't specify a value, Image Builder begins the state update right away. For a scheduled deprecation, included AMIs get their EC2 deprecation time set immediately, and Image Builder schedules the image resource to transition to <code>DEPRECATED</code> at that time.</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.call_rate_limit_exceeded_exception.CallRateLimitExceededException: <p>You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.</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.forbidden_exception.ForbiddenException: <p>You are not authorized to perform the requested operation.</p>
        capo_imagebuilder.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.</p>
        capo_imagebuilder.errors.invalid_request_exception.InvalidRequestException: <p>The request is malformed or otherwise invalid. Verify the request and try again.</p>
        capo_imagebuilder.errors.resource_in_use_exception.ResourceInUseException: <p>The resource that you are trying to operate on is currently in use. Review the message details and retry later.</p>
        capo_imagebuilder.errors.resource_not_found_exception.ResourceNotFoundException: <p>At least one of the resources referenced by your request does not exist.</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.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Schedule an image build version for deprecation
        The following example schedules the specified image build version and its AMI to move to the DEPRECATED state at the requested future time. It returns the ID of the lifecycle execution that applies the update.

        >>> await client.start_resource_state_update(resource_arn='arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-recipe/1.0.0/1', state={'status': 'DEPRECATED'}, execution_role='arn:aws:iam::111122223333:role/my-example-state-update-role', include_resources={'amis': True}, update_at='2026-09-11T21:20:00Z', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE24680')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_imagebuilder.types.start_resource_state_update_request.StartResourceStateUpdateRequest]",
    ) -> AsyncOperationResponse[
        "capo_imagebuilder.types.start_resource_state_update_response.StartResourceStateUpdateResponse"
    ]:
        import capo_imagebuilder._operations.imagebuilder.start_resource_state_update

        (
            output,
            http_response,
        ) = await capo_imagebuilder._operations.imagebuilder.start_resource_state_update.async_start_resource_state_update(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("StartResourceStateUpdate")
    )
    input_: capo_imagebuilder.types.start_resource_state_update_request.StartResourceStateUpdateRequest = {
        "resource_arn": resource_arn,
        "state": state,
        "client_token": client_token,
    }
    if execution_role is not None:
        input_["execution_role"] = execution_role
    if include_resources is not None:
        input_["include_resources"] = include_resources
    if exclusion_rules is not None:
        input_["exclusion_rules"] = exclusion_rules
    if update_at is not None:
        input_["update_at"] = update_at

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output