Skip to content

/AWS1/IF_ECS=>DEREGISTERCONTAINERINSTANCE()

About DeregisterContainerInstance

Deregisters an Amazon ECS container instance from the specified cluster. This instance is no longer available to run tasks.

If you intend to use the container instance for some other purpose after deregistration, we recommend that you stop all of the tasks running on the container instance before deregistration. That prevents any orphaned tasks from consuming resources.

Deregistering a container instance removes the instance from a cluster, but it doesn't terminate the EC2 instance. If you are finished using the instance, be sure to terminate it in the Amazon EC2 console to stop billing.

If you terminate a running container instance, Amazon ECS automatically deregisters the instance from your cluster (stopped container instances or instances with disconnected agents aren't automatically deregistered when terminated).

Method Signature

METHODS /AWS1/IF_ECS~DEREGISTERCONTAINERINSTANCE
  IMPORTING
    !IV_CLUSTER TYPE /AWS1/ECSSTRING OPTIONAL
    !IV_CONTAINERINSTANCE TYPE /AWS1/ECSSTRING OPTIONAL
    !IV_FORCE TYPE /AWS1/ECSBOXEDBOOLEAN OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_ecsderegcontainerin01
  RAISING
    /AWS1/CX_ECSACCESSDENIEDEX
    /AWS1/CX_ECSCLIENTEXCEPTION
    /AWS1/CX_ECSCLUSTERNOTFOUNDEX
    /AWS1/CX_ECSINVALIDPARAMETEREX
    /AWS1/CX_ECSSERVEREXCEPTION
    /AWS1/CX_ECSCLIENTEXC
    /AWS1/CX_ECSSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_containerinstance TYPE /AWS1/ECSSTRING /AWS1/ECSSTRING

The container instance ID or full ARN of the container instance to deregister. For more information about the ARN format, see Amazon Resource Name (ARN) in the Amazon ECS Developer Guide.

Optional arguments:

iv_cluster TYPE /AWS1/ECSSTRING /AWS1/ECSSTRING

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

iv_force TYPE /AWS1/ECSBOXEDBOOLEAN /AWS1/ECSBOXEDBOOLEAN

Forces the container instance to be deregistered. If you have tasks running on the container instance when you deregister it with the force option, these tasks remain running until you terminate the instance or the tasks stop through some other means, but they're orphaned (no longer monitored or accounted for by Amazon ECS). If an orphaned task on your container instance is part of an Amazon ECS service, then the service scheduler starts another copy of that task, on a different container instance if possible.

Any containers in orphaned service tasks that are registered with a Classic Load Balancer or an Application Load Balancer target group are deregistered. They begin connection draining according to the settings on the load balancer or target group.

RETURNING

oo_output TYPE REF TO /aws1/cl_ecsderegcontainerin01 /AWS1/CL_ECSDEREGCONTAINERIN01

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->deregistercontainerinstance(
  iv_cluster = |string|
  iv_containerinstance = |string|
  iv_force = ABAP_TRUE
).

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 deregister a container instance from a cluster

This example deregisters a container instance from the specified cluster in your default region. If there are still tasks running on the container instance, you must either stop those tasks before deregistering, or use the force option.

DATA(lo_result) = lo_client->deregistercontainerinstance(
  iv_cluster = |default|
  iv_containerinstance = |container_instance_UUID|
  iv_force = ABAP_TRUE
).