/AWS1/IF_ECS=>UPDATETASKPROTECTION()¶
About UpdateTaskProtection¶
Updates the protection status of a task. You can set protectionEnabled to
true to protect your task from termination during scale-in events from
Service
Autoscaling or deployments.
Task-protection, by default, expires after 2 hours at which point Amazon ECS clears
the protectionEnabled property making the task eligible for termination by
a subsequent scale-in event.
You can specify a custom expiration period for task protection from 1 minute to up to
2,880 minutes (48 hours). To specify the custom expiration period, set the
expiresInMinutes property. The expiresInMinutes property
is always reset when you invoke this operation for a task that already has
protectionEnabled set to true. You can keep extending the
protection expiration period of a task by invoking this operation repeatedly.
To learn more about Amazon ECS task protection, see Task scale-in protection in the Amazon Elastic Container Service Developer Guide .
This operation is only supported for tasks belonging to an Amazon ECS service.
Invoking this operation for a standalone task will result in an
TASK_NOT_VALID failure. For more information, see API failure
reasons.
If you prefer to set task protection from within the container, we recommend using the Task scale-in protection endpoint.
Method Signature¶
METHODS /AWS1/IF_ECS~UPDATETASKPROTECTION
IMPORTING
!IV_CLUSTER TYPE /AWS1/ECSSTRING OPTIONAL
!IT_TASKS TYPE /AWS1/CL_ECSSTRINGLIST_W=>TT_STRINGLIST OPTIONAL
!IV_PROTECTIONENABLED TYPE /AWS1/ECSBOOLEAN OPTIONAL
!IV_EXPIRESINMINUTES TYPE /AWS1/ECSBOXEDINTEGER OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_ecsuptskprotectionrsp
RAISING
/AWS1/CX_ECSACCESSDENIEDEX
/AWS1/CX_ECSCLIENTEXCEPTION
/AWS1/CX_ECSCLUSTERNOTFOUNDEX
/AWS1/CX_ECSINVALIDPARAMETEREX
/AWS1/CX_ECSRESOURCENOTFOUNDEX
/AWS1/CX_ECSSERVEREXCEPTION
/AWS1/CX_ECSUNSUPPEDFEATUREEX
/AWS1/CX_ECSCLIENTEXC
/AWS1/CX_ECSSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_cluster TYPE /AWS1/ECSSTRING /AWS1/ECSSTRING¶
The short name or full Amazon Resource Name (ARN) of the cluster that hosts the service that the task sets exist in.
it_tasks TYPE /AWS1/CL_ECSSTRINGLIST_W=>TT_STRINGLIST TT_STRINGLIST¶
A list of up to 10 task IDs or full ARN entries.
iv_protectionenabled TYPE /AWS1/ECSBOOLEAN /AWS1/ECSBOOLEAN¶
Specify
trueto mark a task for protection andfalseto unset protection, making it eligible for termination.
Optional arguments:¶
iv_expiresinminutes TYPE /AWS1/ECSBOXEDINTEGER /AWS1/ECSBOXEDINTEGER¶
If you set
protectionEnabledtotrue, you can specify the duration for task protection in minutes. You can specify a value from 1 minute to up to 2,880 minutes (48 hours). During this time, your task will not be terminated by scale-in events from Service Auto Scaling or deployments. After this time period lapses,protectionEnabledwill be reset tofalse.If you don’t specify the time, then the task is automatically protected for 120 minutes (2 hours).
RETURNING¶
oo_output TYPE REF TO /aws1/cl_ecsuptskprotectionrsp /AWS1/CL_ECSUPTSKPROTECTIONRSP¶
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->updatetaskprotection(
it_tasks = VALUE /aws1/cl_ecsstringlist_w=>tt_stringlist(
( new /aws1/cl_ecsstringlist_w( |string| ) )
)
iv_cluster = |string|
iv_expiresinminutes = 123
iv_protectionenabled = 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_protectedtasks( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_string = lo_row_1->get_taskarn( ).
lv_boolean = lo_row_1->get_protectionenabled( ).
lv_timestamp = lo_row_1->get_expirationdate( ).
ENDIF.
ENDLOOP.
LOOP AT lo_result->get_failures( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_string = lo_row_3->get_arn( ).
lv_string = lo_row_3->get_reason( ).
lv_string = lo_row_3->get_detail( ).
ENDIF.
ENDLOOP.
ENDIF.
To remove task scale-in protection¶
This example removes scale-in protection for a task.
DATA(lo_result) = lo_client->updatetaskprotection(
it_tasks = VALUE /aws1/cl_ecsstringlist_w=>tt_stringlist(
( new /aws1/cl_ecsstringlist_w( |b8b1cf532d0e46ba8d44a40d1de16772| ) )
)
iv_cluster = |test-task-protection|
iv_protectionenabled = ABAP_FALSE
).
To set task scale-in protection for a task for 60 minutes¶
This example enables scale-in protection for a task for 60 minutes.
DATA(lo_result) = lo_client->updatetaskprotection(
it_tasks = VALUE /aws1/cl_ecsstringlist_w=>tt_stringlist(
( new /aws1/cl_ecsstringlist_w( |b8b1cf532d0e46ba8d44a40d1de16772| ) )
)
iv_cluster = |test-task-protection|
iv_expiresinminutes = 60
iv_protectionenabled = ABAP_TRUE
).
To set task scale-in protection for the default time period in minutes¶
This example enables task scale-in protection for a task, without specifying the expiresInMinutes parameter, for the default protection period of 120 minutes.
DATA(lo_result) = lo_client->updatetaskprotection(
it_tasks = VALUE /aws1/cl_ecsstringlist_w=>tt_stringlist(
( new /aws1/cl_ecsstringlist_w( |b8b1cf532d0e46ba8d44a40d1de16772| ) )
)
iv_cluster = |test-task-protection|
iv_protectionenabled = ABAP_TRUE
).