-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.go
40 lines (32 loc) · 1013 Bytes
/
storage.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
package ark
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/ssm"
)
// Store the keys to parameter store
// the key is /bei/developers/s3read/access for access key
// the key is /bei/developers/s3read/secret for secret key
// to make things easier in the future, the key should be access like a path
func StoreKeys(sess *session.Session, accessKey *iam.AccessKey) error {
svc := ssm.New(sess)
err := putParameterStoreKey(svc, AccessReaderPathKey, accessKey.AccessKeyId)
err = putParameterStoreKey(svc, SecretReaderPathKey, accessKey.SecretAccessKey)
if err != nil {
return err
}
return nil
}
func putParameterStoreKey(svc *ssm.SSM, key string, value *string) error {
_, err := svc.PutParameter(&ssm.PutParameterInput{
Name: aws.String(key),
Value: value,
Type: aws.String(TypeSecure),
Overwrite: aws.Bool(true),
})
if err != nil {
return err
}
return nil
}