-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws.go
36 lines (28 loc) · 746 Bytes
/
aws.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
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/iam"
)
func Client(cfg aws.Config) *iam.Client {
return iam.NewFromConfig(cfg)
}
type new_key struct {
key string
secret string
}
func CreateKey(ctx context.Context, client *iam.Client) new_key {
keys, err := client.CreateAccessKey(ctx, &iam.CreateAccessKeyInput{})
if err != nil {
Boom("Can't create new key", err)
}
return new_key{
key: *keys.AccessKey.AccessKeyId,
secret: *keys.AccessKey.SecretAccessKey,
}
}
func DeleteKey(ctx context.Context, client *iam.Client, key_id string) error {
input := &iam.DeleteAccessKeyInput{AccessKeyId: &key_id}
_, err := client.DeleteAccessKey(ctx, input)
return err
}