Skip to content

/AWS1/IF_IMG=>STARTRESOURCESTATEUPDATE()

About StartResourceStateUpdate

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.

Method Signature

METHODS /AWS1/IF_IMG~STARTRESOURCESTATEUPDATE
  IMPORTING
    !IV_RESOURCEARN TYPE /AWS1/IMGIMAGEBUILDVERSIONARN OPTIONAL
    !IO_STATE TYPE REF TO /AWS1/CL_IMGRESOURCESTATE OPTIONAL
    !IV_EXECUTIONROLE TYPE /AWS1/IMGROLENAMEORARN OPTIONAL
    !IO_INCLUDERESOURCES TYPE REF TO /AWS1/CL_IMGRESRCSTATEUPINCR00 OPTIONAL
    !IO_EXCLUSIONRULES TYPE REF TO /AWS1/CL_IMGRESRCSTATEUPEXCL00 OPTIONAL
    !IV_UPDATEAT TYPE /AWS1/IMGDATETIMETIMESTAMP OPTIONAL
    !IV_CLIENTTOKEN TYPE /AWS1/IMGCLIENTTOKEN OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_imgstrtresrcstateup01
  RAISING
    /AWS1/CX_IMGCALLRLIMEXCEEDEDEX
    /AWS1/CX_IMGCLIENTEXCEPTION
    /AWS1/CX_IMGFORBIDDENEXCEPTION
    /AWS1/CX_IMGIDEMPOTENTPRMMIS00
    /AWS1/CX_IMGINVALIDREQUESTEX
    /AWS1/CX_IMGRESOURCEINUSEEX
    /AWS1/CX_IMGRESOURCENOTFOUNDEX
    /AWS1/CX_IMGSERVICEEXCEPTION
    /AWS1/CX_IMGSERVICEUNAVAILEX
    /AWS1/CX_IMGCLIENTEXC
    /AWS1/CX_IMGSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_resourcearn TYPE /AWS1/IMGIMAGEBUILDVERSIONARN /AWS1/IMGIMAGEBUILDVERSIONARN

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.

io_state TYPE REF TO /AWS1/CL_IMGRESOURCESTATE /AWS1/CL_IMGRESOURCESTATE

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.

iv_clienttoken TYPE /AWS1/IMGCLIENTTOKEN /AWS1/IMGCLIENTTOKEN

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.

Optional arguments:

iv_executionrole TYPE /AWS1/IMGROLENAMEORARN /AWS1/IMGROLENAMEORARN

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.

io_includeresources TYPE REF TO /AWS1/CL_IMGRESRCSTATEUPINCR00 /AWS1/CL_IMGRESRCSTATEUPINCR00

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.

io_exclusionrules TYPE REF TO /AWS1/CL_IMGRESRCSTATEUPEXCL00 /AWS1/CL_IMGRESRCSTATEUPEXCL00

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.

iv_updateat TYPE /AWS1/IMGDATETIMETIMESTAMP /AWS1/IMGDATETIMETIMESTAMP

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.

RETURNING

oo_output TYPE REF TO /aws1/cl_imgstrtresrcstateup01 /AWS1/CL_IMGSTRTRESRCSTATEUP01

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->startresourcestateupdate(
  io_exclusionrules = new /aws1/cl_imgresrcstateupexcl00(
    io_amis = new /aws1/cl_imglcplydetexclusio01(
      io_lastlaunched = new /aws1/cl_imglcplydetexclusio02(
        iv_unit = |string|
        iv_value = 123
      )
      it_regions = VALUE /aws1/cl_imgstringlist_w=>tt_stringlist(
        ( new /aws1/cl_imgstringlist_w( |string| ) )
      )
      it_sharedaccounts = VALUE /aws1/cl_imgaccountlist_w=>tt_accountlist(
        ( new /aws1/cl_imgaccountlist_w( |string| ) )
      )
      it_tagmap = VALUE /aws1/cl_imgtagmap_w=>tt_tagmap(
        (
          VALUE /aws1/cl_imgtagmap_w=>ts_tagmap_maprow(
            key = |string|
            value = new /aws1/cl_imgtagmap_w( |string| )
          )
        )
      )
      iv_ispublic = ABAP_TRUE
    )
  )
  io_includeresources = new /aws1/cl_imgresrcstateupincr00(
    iv_amis = ABAP_TRUE
    iv_containers = ABAP_TRUE
    iv_snapshots = ABAP_TRUE
  )
  io_state = new /aws1/cl_imgresourcestate( |string| )
  iv_clienttoken = |string|
  iv_executionrole = |string|
  iv_resourcearn = |string|
  iv_updateat = '20150101000000.0000000'
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_lifecycleexecutionid = lo_result->get_lifecycleexecutionid( ).
  lv_imagebuildversionarn = lo_result->get_resourcearn( ).
ENDIF.

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.

DATA(lo_result) = lo_client->startresourcestateupdate(
  io_includeresources = new /aws1/cl_imgresrcstateupincr00( iv_amis = ABAP_TRUE )
  io_state = new /aws1/cl_imgresourcestate( |DEPRECATED| )
  iv_clienttoken = |a1b2c3d4-5678-90ab-cdef-EXAMPLE24680|
  iv_executionrole = |arn:aws:iam::111122223333:role/my-example-state-update-role|
  iv_resourcearn = |arn:aws:imagebuilder:us-west-2:111122223333:image/my-example-recipe/1.0.0/1|
  iv_updateat = '20260911212000.0000000'
).