Documentation ¶
Overview ¶
Package ecstp (ecs-task-protection) provides an easy function for enabling and disabling ECS task termination protection and can be called from inside an ECS task. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-scale-in-protection.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpdateTaskProtection ¶
func UpdateTaskProtection(input *UpdateTaskProtectionInput) error
UpdateTaskProtection uses the provided input to enable or disable task protection.
UpdateTaskProtection makes calls GetTaskArn to retrieve the Cluster and Task ARN and then calls the UpdateTaskProtection ECS API to enable or disable protection. Returns any errors from the ECS API or an error if task protection fails to enable.
Types ¶
type MetadataBody ¶
MetadataBody represents the JSON body returned from the metadata task API
func GetTaskArn ¶
func GetTaskArn() (*MetadataBody, error)
GetTaskArn calls the Instance metadata API to retrieve the current Cluster and Task ARN.
The Instance metadata API URI is obtained through the env variable `ECS_CONTAINER_METADATA_URI_V4`. Returns a pointer to struct MetadataBody representing the API response or returns an error if the env variable cannot be found, the API was unreachable or the response can't be unmarshalled.
type UpdateTaskProtectionInput ¶
type UpdateTaskProtectionInput struct { Context context.Context Client *ecs.Client Protect bool ExpiresInMinutes *int32 }
UpdateTaskProtectionInput defines the parameters required for UpdateTaskProtection.
Client must not be nil. ExpiresInMinutes must be between 1 and 2880, but can be nil. Setting to nil will use the default protection period. See https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-scale-in-protection.html