forked from gruntwork-io/cloud-nuke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
creds.go
38 lines (30 loc) · 738 Bytes
/
creds.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
package externalcreds
import (
"os"
"github.com/gruntwork-io/cloud-nuke/telemetry"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
)
var externalConfig *aws.Config
func Set(opts *aws.Config) {
os.Setenv("DISABLE_TELEMETRY", "true")
telemetry.InitTelemetry("", "")
externalConfig = opts
}
func Get(region string) *session.Session {
config := aws.Config{
Region: aws.String(region),
}
// If external config was passed in, use its credentials
if externalConfig != nil {
config.Credentials = externalConfig.Credentials
}
return session.Must(
session.NewSessionWithOptions(
session.Options{
SharedConfigState: session.SharedConfigEnable,
Config: config,
},
),
)
}