Skip to content

/AWS1/IF_EC2=>DELETEFLEETS()

About DeleteFleets

Deletes the specified EC2 Fleet request.

After you delete an EC2 Fleet request, it launches no new instances.

You must also specify whether a deleted EC2 Fleet request should terminate its instances. If you choose to terminate the instances, the EC2 Fleet request enters the deleted_terminating state. Otherwise, it enters the deleted_running state, and the instances continue to run until they are interrupted or you terminate them manually.

A deleted instant fleet with running instances is not supported. When you delete an instant fleet, Amazon EC2 automatically terminates all its instances. For fleets with more than 1000 instances, the deletion request might fail. If your fleet has more than 1000 instances, first terminate most of the instances manually, leaving 1000 or fewer. Then delete the fleet, and the remaining instances will be terminated automatically.

Terminating an instance is permanent and irreversible.

After you terminate an instance, you can no longer connect to it, and it can't be recovered. All attached Amazon EBS volumes that are configured to be deleted on termination are also permanently deleted and can't be recovered. All data stored on instance store volumes is permanently lost. For more information, see How instance termination works.

Before you terminate an instance, ensure that you have backed up all data that you need to retain after the termination to persistent storage.

Restrictions

  • You can delete up to 25 fleets of type instant in a single request.

  • You can delete up to 100 fleets of type maintain or request in a single request.

  • You can delete up to 125 fleets in a single request, provided you do not exceed the quota for each fleet type, as specified above.

  • If you exceed the specified number of fleets to delete, no fleets are deleted.

For more information, see Delete an EC2 Fleet request and the instances in the fleet in the Amazon EC2 User Guide.

Method Signature

METHODS /AWS1/IF_EC2~DELETEFLEETS
  IMPORTING
    !IV_DRYRUN TYPE /AWS1/EC2BOOLEAN OPTIONAL
    !IT_FLEETIDS TYPE /AWS1/CL_EC2FLEETIDSET_W=>TT_FLEETIDSET OPTIONAL
    !IV_TERMINATEINSTANCES TYPE /AWS1/EC2BOOLEAN OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_ec2deletefleetsresult
  RAISING
    /AWS1/CX_EC2CLIENTEXC
    /AWS1/CX_EC2SERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

it_fleetids TYPE /AWS1/CL_EC2FLEETIDSET_W=>TT_FLEETIDSET TT_FLEETIDSET

The IDs of the EC2 Fleets.

Constraints: In a single request, you can specify up to 25 instant fleet IDs and up to 100 maintain or request fleet IDs.

iv_terminateinstances TYPE /AWS1/EC2BOOLEAN /AWS1/EC2BOOLEAN

Indicates whether to terminate the associated instances when the EC2 Fleet is deleted. The default is to terminate the instances.

To let the instances continue to run after the EC2 Fleet is deleted, specify no-terminate-instances. Supported only for fleets of type maintain and request.

For instant fleets, you cannot specify NoTerminateInstances. A deleted instant fleet with running instances is not supported.

Optional arguments:

iv_dryrun TYPE /AWS1/EC2BOOLEAN /AWS1/EC2BOOLEAN

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

RETURNING

oo_output TYPE REF TO /aws1/cl_ec2deletefleetsresult /AWS1/CL_EC2DELETEFLEETSRESULT

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->deletefleets(
  it_fleetids = VALUE /aws1/cl_ec2fleetidset_w=>tt_fleetidset(
    ( new /aws1/cl_ec2fleetidset_w( |string| ) )
  )
  iv_dryrun = ABAP_TRUE
  iv_terminateinstances = ABAP_TRUE
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  LOOP AT lo_result->get_successfulfleetdeletions( ) into lo_row.
    lo_row_1 = lo_row.
    IF lo_row_1 IS NOT INITIAL.
      lv_fleetstatecode = lo_row_1->get_currentfleetstate( ).
      lv_fleetstatecode = lo_row_1->get_previousfleetstate( ).
      lv_fleetid = lo_row_1->get_fleetid( ).
    ENDIF.
  ENDLOOP.
  LOOP AT lo_result->get_unsuccessfulfleetdels( ) into lo_row_2.
    lo_row_3 = lo_row_2.
    IF lo_row_3 IS NOT INITIAL.
      lo_deletefleeterror = lo_row_3->get_error( ).
      IF lo_deletefleeterror IS NOT INITIAL.
        lv_deletefleeterrorcode = lo_deletefleeterror->get_code( ).
        lv_string = lo_deletefleeterror->get_message( ).
      ENDIF.
      lv_fleetid = lo_row_3->get_fleetid( ).
    ENDIF.
  ENDLOOP.
ENDIF.