Skip to content

/AWS1/CL_ECS=>UPDATECONTAINERAGENT()

About UpdateContainerAgent

Updates the Amazon ECS container agent on a specified container instance. Updating the Amazon ECS container agent doesn't interrupt running tasks or services on the container instance. The process for updating the agent differs depending on whether your container instance was launched with the Amazon ECS-optimized AMI or another operating system.

The UpdateContainerAgent API isn't supported for container instances using the Amazon ECS-optimized Amazon Linux 2 (arm64) AMI. To update the container agent, you can update the ecs-init package. This updates the agent. For more information, see Updating the Amazon ECS container agent in the Amazon Elastic Container Service Developer Guide.

Agent updates with the UpdateContainerAgent API operation do not apply to Windows container instances. We recommend that you launch new container instances to update the agent version in your Windows clusters.

The UpdateContainerAgent API requires an Amazon ECS-optimized AMI or Amazon Linux AMI with the ecs-init service installed and running. For help updating the Amazon ECS container agent on other operating systems, see Manually updating the Amazon ECS container agent in the Amazon Elastic Container Service Developer Guide.

Method Signature

IMPORTING

Required arguments:

iv_containerinstance TYPE /AWS1/ECSSTRING /AWS1/ECSSTRING

The container instance ID or full ARN entries for the container instance where you would like to update the Amazon ECS container agent.

Optional arguments:

iv_cluster TYPE /AWS1/ECSSTRING /AWS1/ECSSTRING

The short name or full Amazon Resource Name (ARN) of the cluster that your container instance is running on. If you do not specify a cluster, the default cluster is assumed.

RETURNING

oo_output TYPE REF TO /aws1/cl_ecsupcontaineragent01 /AWS1/CL_ECSUPCONTAINERAGENT01

Domain /AWS1/RT_ACCOUNT_ID
Primitive Type NUMC

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->/aws1/if_ecs~updatecontaineragent(
  iv_cluster = |string|
  iv_containerinstance = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lo_containerinstance = lo_result->get_containerinstance( ).
  IF lo_containerinstance IS NOT INITIAL.
    lv_string = lo_containerinstance->get_containerinstancearn( ).
    lv_string = lo_containerinstance->get_ec2instanceid( ).
    lv_string = lo_containerinstance->get_capacityprovidername( ).
    lv_long = lo_containerinstance->get_version( ).
    lo_versioninfo = lo_containerinstance->get_versioninfo( ).
    IF lo_versioninfo IS NOT INITIAL.
      lv_string = lo_versioninfo->get_agentversion( ).
      lv_string = lo_versioninfo->get_agenthash( ).
      lv_string = lo_versioninfo->get_dockerversion( ).
    ENDIF.
    LOOP AT lo_containerinstance->get_remainingresources( ) into lo_row.
      lo_row_1 = lo_row.
      IF lo_row_1 IS NOT INITIAL.
        lv_string = lo_row_1->get_name( ).
        lv_string = lo_row_1->get_type( ).
        lv_double = lo_row_1->get_doublevalue( ).
        lv_long = lo_row_1->get_longvalue( ).
        lv_integer = lo_row_1->get_integervalue( ).
        LOOP AT lo_row_1->get_stringsetvalue( ) into lo_row_2.
          lo_row_3 = lo_row_2.
          IF lo_row_3 IS NOT INITIAL.
            lv_string = lo_row_3->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_containerinstance->get_registeredresources( ) into lo_row.
      lo_row_1 = lo_row.
      IF lo_row_1 IS NOT INITIAL.
        lv_string = lo_row_1->get_name( ).
        lv_string = lo_row_1->get_type( ).
        lv_double = lo_row_1->get_doublevalue( ).
        lv_long = lo_row_1->get_longvalue( ).
        lv_integer = lo_row_1->get_integervalue( ).
        LOOP AT lo_row_1->get_stringsetvalue( ) into lo_row_2.
          lo_row_3 = lo_row_2.
          IF lo_row_3 IS NOT INITIAL.
            lv_string = lo_row_3->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    lv_string = lo_containerinstance->get_status( ).
    lv_string = lo_containerinstance->get_statusreason( ).
    lv_boolean = lo_containerinstance->get_agentconnected( ).
    lv_integer = lo_containerinstance->get_runningtaskscount( ).
    lv_integer = lo_containerinstance->get_pendingtaskscount( ).
    lv_agentupdatestatus = lo_containerinstance->get_agentupdatestatus( ).
    LOOP AT lo_containerinstance->get_attributes( ) into lo_row_4.
      lo_row_5 = lo_row_4.
      IF lo_row_5 IS NOT INITIAL.
        lv_string = lo_row_5->get_name( ).
        lv_string = lo_row_5->get_value( ).
        lv_targettype = lo_row_5->get_targettype( ).
        lv_string = lo_row_5->get_targetid( ).
      ENDIF.
    ENDLOOP.
    lv_timestamp = lo_containerinstance->get_registeredat( ).
    LOOP AT lo_containerinstance->get_attachments( ) into lo_row_6.
      lo_row_7 = lo_row_6.
      IF lo_row_7 IS NOT INITIAL.
        lv_string = lo_row_7->get_id( ).
        lv_string = lo_row_7->get_type( ).
        lv_string = lo_row_7->get_status( ).
        LOOP AT lo_row_7->get_details( ) into lo_row_8.
          lo_row_9 = lo_row_8.
          IF lo_row_9 IS NOT INITIAL.
            lv_string = lo_row_9->get_name( ).
            lv_string = lo_row_9->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_containerinstance->get_tags( ) into lo_row_10.
      lo_row_11 = lo_row_10.
      IF lo_row_11 IS NOT INITIAL.
        lv_tagkey = lo_row_11->get_key( ).
        lv_tagvalue = lo_row_11->get_value( ).
      ENDIF.
    ENDLOOP.
    lo_containerinstancehealth = lo_containerinstance->get_healthstatus( ).
    IF lo_containerinstancehealth IS NOT INITIAL.
      lv_instancehealthcheckstat = lo_containerinstancehealth->get_overallstatus( ).
      LOOP AT lo_containerinstancehealth->get_details( ) into lo_row_12.
        lo_row_13 = lo_row_12.
        IF lo_row_13 IS NOT INITIAL.
          lv_instancehealthchecktype = lo_row_13->get_type( ).
          lv_instancehealthcheckstat = lo_row_13->get_status( ).
          lv_timestamp = lo_row_13->get_lastupdated( ).
          lv_timestamp = lo_row_13->get_laststatuschange( ).
        ENDIF.
      ENDLOOP.
    ENDIF.
  ENDIF.
ENDIF.

To update the container agent version on a container instance

This example updates the container agent version on the specified container instance in cluster MyCluster.

DATA(lo_result) = lo_client->/aws1/if_ecs~updatecontaineragent(
  iv_cluster = |MyCluster|
  iv_containerinstance = |53ac7152-dcd1-4102-81f5-208962864132|
).