Skip to content

Small Go module to enable/disable scale-in protection from inside an ECS task

License

Notifications You must be signed in to change notification settings

Thumbscrew/ecs-task-protection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ecs-task-protection

GoAPI Reference

Small Go module to enable/disable protection for an ECS task.

Example usage

// create ECS client
ecsClient := ecs.New(ecs.Options{})

// create task protection client
protClient := ecstp.NewClient(ecsClient)

// enable protection
output, err := protClient.UpdateTaskProtection(context.Background(), &ecstp.UpdateTaskProtectionInput{
    Protect: true,
})

// disable protection
out, err := protClient.UpdateTaskProtection(context.Background(), &ecstp.UpdateTaskProtectionInput{
    Protect: false,
})

// enable protection with 60 minute expiry
out, err := protClient.UpdateTaskProtection(context.Background(), &ecstp.UpdateTaskProtectionInput{
    Protect: true,
    ExpiresInMinutes: aws.Int32(60),
})

// get Cluster and TaskARN metadata
body, err := protClient.GetTaskArn(context.Background())

// enable protection with provided metadata
out, err := protClient.UpdateTaskProtection(context.Background(), &ecstp.UpdateTaskProtectionInput{
    Metadata: &ecstp.MetadataBody{
        Cluster: "test-cluster",
        TaskARN: "arn:aws:ecs:eu-west-2:123456789012:task/example/taskid",
    },
    Protect: true,
})

About

Small Go module to enable/disable scale-in protection from inside an ECS task

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages