-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (38 loc) · 1.18 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// usage: s3-get-bucket-location endpoint AKID SAK region bucket
package main
import (
"context"
"flag"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go/aws"
)
func main() {
flag.Parse()
if n := flag.NArg(); n != 5 {
log.Fatalf("not enough/too many args (has %d, needs 5)", n)
}
client := s3.New(s3.Options{
BaseEndpoint: aws.String(flag.Arg(0)),
Credentials: credentials.NewStaticCredentialsProvider(flag.Arg(1), flag.Arg(2), ""),
Region: flag.Arg(3),
})
out, err := client.GetObjectLockConfiguration(context.Background(), &s3.GetObjectLockConfigurationInput{
Bucket: aws.String(flag.Arg(4)),
})
if err != nil {
log.Panicf("GetObjectLockConfiguration: %v", err)
}
if out.ObjectLockConfiguration != nil {
fmt.Printf("ObjectLockConfiguration.ObjectLockEnabled is %v\n", out.ObjectLockConfiguration.ObjectLockEnabled)
if out.ObjectLockConfiguration.Rule != nil {
fmt.Printf("ObjectLockConfiguration.Rule is %v\n", out.ObjectLockConfiguration.Rule)
} else {
fmt.Println("ObjectLockConfiguration.Rule is <nil>")
}
} else {
fmt.Println("ObjectLockConfiguration is <nil>")
}
}