imagebuilder / Client / start_resource_state_update

start_resource_state_update

imagebuilder.Client.start_resource_state_update(**kwargs)

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.

See also: AWS API Documentation

Request Syntax

response = client.start_resource_state_update(
    resourceArn='string',
    state={
        'status': 'AVAILABLE'|'DELETED'|'DEPRECATED'|'DISABLED'
    },
    executionRole='string',
    includeResources={
        'amis': True|False,
        'snapshots': True|False,
        'containers': True|False
    },
    exclusionRules={
        'amis': {
            'isPublic': True|False,
            'regions': [
                'string',
            ],
            'sharedAccounts': [
                'string',
            ],
            'lastLaunched': {
                'value': 123,
                'unit': 'DAYS'|'WEEKS'|'MONTHS'|'YEARS'
            },
            'tagMap': {
                'string': 'string'
            }
        }
    },
    updateAt=datetime(2015, 1, 1),
    clientToken='string'
)
Parameters:
  • resourceArn (string) –

    [REQUIRED]

    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 (dict) –

    [REQUIRED]

    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.

    • status (string) –

      The status to which you want to move the image resource. Set the status to AVAILABLE to restore an image that’s currently deprecated or disabled.

  • executionRole (string) – 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.

  • includeResources (dict) –

    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.

    • amis (boolean) –

      Specifies whether the lifecycle action should apply to distributed AMIs.

    • snapshots (boolean) –

      Specifies whether the lifecycle action should apply to snapshots associated with distributed AMIs.

    • containers (boolean) –

      Specifies whether the lifecycle action should apply to distributed containers.

  • exclusionRules (dict) –

    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.

    • amis (dict) –

      Defines criteria for AMIs that Image Builder should exclude from the resource state update.

      • isPublic (boolean) –

        Configures whether public AMIs are excluded from the lifecycle action.

      • regions (list) –

        Configures Amazon Web Services Regions that are excluded from the lifecycle action.

        • (string) –

      • sharedAccounts (list) –

        The lifecycle action doesn’t apply to AMIs that are shared with any of the specified Amazon Web Services accounts.

        • (string) –

      • lastLaunched (dict) –

        Configures Image Builder to exclude AMIs that were launched within the specified time period from lifecycle actions. AMIs with no recorded last-launched time aren’t excluded by this rule.

        • value (integer) – [REQUIRED]

          The integer number of units for the time period. For example 6 (months).

        • unit (string) – [REQUIRED]

          Defines the unit of time that the lifecycle policy uses to calculate elapsed time since the last launch.

      • tagMap (dict) –

        Lifecycle actions don’t apply to AMIs that have any of these tags. Both the key and the value must match.

        • (string) –

          • (string) –

  • updateAt (datetime) – 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.

  • clientToken (string) –

    [REQUIRED]

    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.

    This field is autopopulated if not provided.

Return type:

dict

Returns:

Response Syntax

{
    'lifecycleExecutionId': 'string',
    'resourceArn': 'string'
}

Response Structure

  • (dict) –

    • lifecycleExecutionId (string) –

      Identifies the lifecycle execution that performs the resource state update. Image Builder only returns this field when it started a lifecycle execution for the update. Use it with GetLifecycleExecution to track progress.

    • resourceArn (string) –

      The requested Amazon Resource Name (ARN) of the Image Builder resource for the asynchronous update.

Exceptions

  • imagebuilder.Client.exceptions.ServiceException

  • imagebuilder.Client.exceptions.ClientException

  • imagebuilder.Client.exceptions.ServiceUnavailableException

  • imagebuilder.Client.exceptions.InvalidRequestException

  • imagebuilder.Client.exceptions.ResourceNotFoundException

  • imagebuilder.Client.exceptions.IdempotentParameterMismatchException

  • imagebuilder.Client.exceptions.ForbiddenException

  • imagebuilder.Client.exceptions.CallRateLimitExceededException

  • imagebuilder.Client.exceptions.ResourceInUseException