-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74cac32
commit 84e387d
Showing
1 changed file
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
# ecs-task-protection | ||
Small Go module to enable/disable protection for an ECS task | ||
[![Go](https://github.com/Thumbscrew/ecs-task-protection/actions/workflows/go.yml/badge.svg)](https://github.com/Thumbscrew/ecs-task-protection/actions/workflows/go.yml)[![API Reference](https://img.shields.io/badge/api-reference-blue.svg)](https://pkg.go.dev/github.com/Thumbscrew/ecs-task-protection) | ||
|
||
Small Go module to enable/disable protection for an ECS task. | ||
|
||
## Example usage | ||
|
||
```go | ||
// 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, | ||
}) | ||
``` |