forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
44 lines (34 loc) · 877 Bytes
/
config.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
package aws
import (
"errors"
goaws "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
)
type Config struct {
AccessKeyID string
SecretAccessKey string
Region string
EndpointOverride string
}
func (c Config) ValidateCredentials() error {
if c.AccessKeyID == "" {
return errors.New("--aws-access-key-id must be provided")
}
if c.SecretAccessKey == "" {
return errors.New("--aws-secret-access-key must be provided")
}
if c.Region == "" {
return errors.New("--aws-region must be provided")
}
return nil
}
func (c Config) ClientConfig() *goaws.Config {
awsConfig := &goaws.Config{
Credentials: credentials.NewStaticCredentials(c.AccessKeyID, c.SecretAccessKey, ""),
Region: goaws.String(c.Region),
}
if c.EndpointOverride != "" {
awsConfig.WithEndpoint(c.EndpointOverride)
}
return awsConfig
}