2020-07-20 11:48:05 +03:00
|
|
|
/*
|
2020-09-22 13:13:00 +03:00
|
|
|
Copyright 2020 Docker Compose CLI authors
|
2020-08-17 17:20:02 +03:00
|
|
|
|
2020-07-20 11:48:05 +03:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
2020-08-17 17:20:02 +03:00
|
|
|
|
2020-07-20 11:48:05 +03:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2020-08-17 17:20:02 +03:00
|
|
|
|
2020-07-20 11:48:05 +03:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2020-07-29 16:12:45 +03:00
|
|
|
package ecs
|
2020-07-15 16:09:05 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2020-11-02 18:24:35 +03:00
|
|
|
"path/filepath"
|
|
|
|
"sort"
|
2020-07-15 16:09:05 +03:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/AlecAivazis/survey/v2/terminal"
|
2020-11-02 18:24:35 +03:00
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
2020-07-15 16:09:05 +03:00
|
|
|
"github.com/aws/aws-sdk-go/aws/credentials"
|
|
|
|
"github.com/aws/aws-sdk-go/aws/defaults"
|
2020-11-02 18:24:35 +03:00
|
|
|
"github.com/aws/aws-sdk-go/aws/session"
|
|
|
|
"github.com/aws/aws-sdk-go/service/ec2"
|
2021-08-31 20:08:07 +03:00
|
|
|
"github.com/docker/compose/v2/pkg/api"
|
|
|
|
"github.com/docker/compose/v2/pkg/prompt"
|
2020-11-02 18:24:35 +03:00
|
|
|
"github.com/pkg/errors"
|
2020-07-29 16:12:45 +03:00
|
|
|
"gopkg.in/ini.v1"
|
2021-08-31 20:08:07 +03:00
|
|
|
|
|
|
|
"github.com/docker/compose-cli/api/context/store"
|
2020-07-15 16:09:05 +03:00
|
|
|
)
|
|
|
|
|
2020-10-29 12:08:41 +03:00
|
|
|
func getEnvVars() ContextParams {
|
2020-10-30 19:42:57 +03:00
|
|
|
c := ContextParams{
|
|
|
|
Profile: os.Getenv("AWS_PROFILE"),
|
|
|
|
Region: os.Getenv("AWS_REGION"),
|
|
|
|
}
|
2020-10-29 12:51:57 +03:00
|
|
|
if c.Region == "" {
|
2020-10-30 19:42:57 +03:00
|
|
|
defaultRegion := os.Getenv("AWS_DEFAULT_REGION")
|
|
|
|
if defaultRegion == "" {
|
|
|
|
defaultRegion = "us-east-1"
|
2020-10-29 12:08:41 +03:00
|
|
|
}
|
2020-10-30 19:42:57 +03:00
|
|
|
c.Region = defaultRegion
|
2020-10-29 12:08:41 +03:00
|
|
|
}
|
2020-10-28 12:54:10 +03:00
|
|
|
|
|
|
|
p := credentials.EnvProvider{}
|
|
|
|
creds, err := p.Retrieve()
|
|
|
|
if err != nil {
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
c.AccessKey = creds.AccessKeyID
|
|
|
|
c.SecretKey = creds.SecretAccessKey
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2020-10-29 12:08:41 +03:00
|
|
|
type contextCreateAWSHelper struct {
|
2020-11-02 18:24:35 +03:00
|
|
|
user prompt.UI
|
|
|
|
availableRegions func(opts *ContextParams) ([]string, error)
|
2020-10-29 12:08:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func newContextCreateHelper() contextCreateAWSHelper {
|
|
|
|
return contextCreateAWSHelper{
|
2020-11-02 18:24:35 +03:00
|
|
|
user: prompt.User{},
|
|
|
|
availableRegions: listAvailableRegions,
|
2020-10-29 12:08:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-30 20:50:56 +03:00
|
|
|
func (h contextCreateAWSHelper) createContextData(_ context.Context, opts ContextParams) (interface{}, string, error) {
|
|
|
|
if opts.CredsFromEnv {
|
2020-11-02 18:24:35 +03:00
|
|
|
// Explicit creation from ENV variables
|
2020-10-30 20:50:56 +03:00
|
|
|
ecsCtx, descr := h.createContext(&opts)
|
|
|
|
return ecsCtx, descr, nil
|
2020-11-02 18:24:35 +03:00
|
|
|
} else if opts.AccessKey != "" && opts.SecretKey != "" {
|
|
|
|
// Explicit creation using keys
|
|
|
|
err := h.createProfileFromCredentials(&opts)
|
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
}
|
|
|
|
} else if opts.Profile != "" {
|
|
|
|
// Excplicit creation by selecting a profile
|
2020-10-30 20:50:56 +03:00
|
|
|
// check profile exists
|
|
|
|
profilesList, err := getProfiles()
|
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
}
|
|
|
|
if !contains(profilesList, opts.Profile) {
|
2021-06-14 17:26:14 +03:00
|
|
|
return nil, "", errors.Wrapf(api.ErrNotFound, "profile %q not found", opts.Profile)
|
2020-10-30 20:50:56 +03:00
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
} else {
|
|
|
|
// interactive
|
|
|
|
var options []string
|
|
|
|
var actions []func(params *ContextParams) error
|
|
|
|
|
|
|
|
if _, err := os.Stat(getAWSConfigFile()); err == nil {
|
|
|
|
// User has .aws/config file, so we can offer to select one of his profiles
|
|
|
|
options = append(options, "An existing AWS profile")
|
|
|
|
actions = append(actions, h.selectFromLocalProfile)
|
2020-10-30 20:50:56 +03:00
|
|
|
}
|
|
|
|
|
2020-11-02 18:24:35 +03:00
|
|
|
options = append(options, "AWS secret and token credentials")
|
|
|
|
actions = append(actions, h.createProfileFromCredentials)
|
2020-10-30 20:50:56 +03:00
|
|
|
|
2020-11-02 18:24:35 +03:00
|
|
|
options = append(options, "AWS environment variables")
|
|
|
|
actions = append(actions, func(params *ContextParams) error {
|
|
|
|
opts.CredsFromEnv = true
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
selected, err := h.user.Select("Create a Docker context using:", options)
|
|
|
|
if err != nil {
|
|
|
|
if err == terminal.InterruptErr {
|
2021-06-14 17:26:14 +03:00
|
|
|
return nil, "", api.ErrCanceled
|
2020-11-02 18:24:35 +03:00
|
|
|
}
|
|
|
|
return nil, "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = actions[selected](&opts)
|
|
|
|
if err != nil {
|
|
|
|
return nil, "", err
|
|
|
|
}
|
2020-10-30 20:50:56 +03:00
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
|
2020-10-30 20:50:56 +03:00
|
|
|
ecsCtx, descr := h.createContext(&opts)
|
|
|
|
return ecsCtx, descr, nil
|
|
|
|
}
|
|
|
|
|
2020-10-29 12:08:41 +03:00
|
|
|
func (h contextCreateAWSHelper) createContext(c *ContextParams) (interface{}, string) {
|
|
|
|
var description string
|
|
|
|
|
2020-10-28 12:54:10 +03:00
|
|
|
if c.CredsFromEnv {
|
2020-10-29 12:08:41 +03:00
|
|
|
if c.Description == "" {
|
|
|
|
description = "credentials read from environment"
|
|
|
|
}
|
2020-10-28 12:54:10 +03:00
|
|
|
return store.EcsContext{
|
|
|
|
CredentialsFromEnv: c.CredsFromEnv,
|
|
|
|
Profile: c.Profile,
|
|
|
|
}, description
|
|
|
|
}
|
2020-10-29 12:08:41 +03:00
|
|
|
|
|
|
|
if c.Region != "" {
|
|
|
|
description = strings.TrimSpace(
|
|
|
|
fmt.Sprintf("%s (%s)", c.Description, c.Region))
|
|
|
|
}
|
2020-10-09 20:24:37 +03:00
|
|
|
return store.EcsContext{
|
2020-10-28 12:54:10 +03:00
|
|
|
Profile: c.Profile,
|
2020-10-09 20:24:37 +03:00
|
|
|
}, description
|
|
|
|
}
|
2020-07-15 16:09:05 +03:00
|
|
|
|
2020-10-29 13:02:46 +03:00
|
|
|
func (h contextCreateAWSHelper) selectFromLocalProfile(opts *ContextParams) error {
|
|
|
|
profilesList, err := getProfiles()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
opts.Profile, err = h.chooseProfile(profilesList)
|
2020-10-30 19:42:57 +03:00
|
|
|
return err
|
2020-10-29 13:02:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h contextCreateAWSHelper) createProfileFromCredentials(opts *ContextParams) error {
|
2020-11-02 18:24:35 +03:00
|
|
|
if opts.AccessKey == "" || opts.SecretKey == "" {
|
|
|
|
fmt.Println("Retrieve or create AWS Access Key and Secret on https://console.aws.amazon.com/iam/home?#security_credential")
|
|
|
|
accessKey, secretKey, err := h.askCredentials()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
opts.AccessKey = accessKey
|
|
|
|
opts.SecretKey = secretKey
|
2020-10-29 13:02:46 +03:00
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
|
|
|
|
if opts.Region == "" {
|
|
|
|
err := h.chooseRegion(opts)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-10-29 13:02:46 +03:00
|
|
|
}
|
|
|
|
// save as a profile
|
|
|
|
if opts.Profile == "" {
|
2020-11-02 18:24:35 +03:00
|
|
|
opts.Profile = "default"
|
2020-10-30 19:42:57 +03:00
|
|
|
}
|
|
|
|
// context name used as profile name
|
2020-11-02 18:24:35 +03:00
|
|
|
err := h.saveCredentials(opts.Profile, opts.AccessKey, opts.SecretKey)
|
2020-10-30 19:42:57 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
return h.saveRegion(opts.Profile, opts.Region)
|
2020-10-29 13:02:46 +03:00
|
|
|
}
|
|
|
|
|
2020-07-15 16:09:05 +03:00
|
|
|
func (h contextCreateAWSHelper) saveCredentials(profile string, accessKeyID string, secretAccessKey string) error {
|
2020-11-02 18:24:35 +03:00
|
|
|
file := getAWSCredentialsFile()
|
|
|
|
err := os.MkdirAll(filepath.Dir(file), 0700)
|
2020-07-15 16:09:05 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
|
2020-11-16 16:50:39 +03:00
|
|
|
credentials, err := ini.Load(file)
|
|
|
|
if err != nil {
|
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
credentials = ini.Empty()
|
|
|
|
}
|
|
|
|
|
|
|
|
section, err := credentials.NewSection(profile)
|
2020-07-15 16:09:05 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-07-16 17:32:37 +03:00
|
|
|
_, err = section.NewKey("aws_access_key_id", accessKeyID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
_, err = section.NewKey("aws_secret_access_key", secretAccessKey)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-16 16:50:39 +03:00
|
|
|
return credentials.SaveTo(file)
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
|
|
|
|
2020-10-30 19:42:57 +03:00
|
|
|
func (h contextCreateAWSHelper) saveRegion(profile, region string) error {
|
|
|
|
if region == "" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
// loads ~/.aws/config
|
2020-11-02 18:24:35 +03:00
|
|
|
awsConfig := getAWSConfigFile()
|
2020-10-30 19:42:57 +03:00
|
|
|
configIni, err := ini.Load(awsConfig)
|
|
|
|
if err != nil {
|
|
|
|
if !os.IsNotExist(err) {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
configIni = ini.Empty()
|
|
|
|
}
|
|
|
|
profile = fmt.Sprintf("profile %s", profile)
|
|
|
|
section, err := configIni.GetSection(profile)
|
|
|
|
if err != nil {
|
|
|
|
if !strings.Contains(err.Error(), "does not exist") {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
section, err = configIni.NewSection(profile)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// save region under profile section in ~/.aws/config
|
|
|
|
_, err = section.NewKey("region", region)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return configIni.SaveTo(awsConfig)
|
|
|
|
}
|
|
|
|
|
2020-10-29 12:08:41 +03:00
|
|
|
func getProfiles() ([]string, error) {
|
2020-10-09 20:24:37 +03:00
|
|
|
profiles := []string{}
|
|
|
|
// parse both .aws/credentials and .aws/config for profiles
|
|
|
|
configFiles := map[string]bool{
|
2020-11-02 18:24:35 +03:00
|
|
|
getAWSCredentialsFile(): false,
|
|
|
|
getAWSConfigFile(): true,
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
2020-10-09 20:24:37 +03:00
|
|
|
for f, prefix := range configFiles {
|
|
|
|
sections, err := loadIniFile(f, prefix)
|
|
|
|
if err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
for key := range sections {
|
|
|
|
name := strings.ToLower(key)
|
|
|
|
if !contains(profiles, name) {
|
|
|
|
profiles = append(profiles, name)
|
|
|
|
}
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
sort.Slice(profiles, func(i, j int) bool {
|
|
|
|
return profiles[i] < profiles[j]
|
|
|
|
})
|
|
|
|
|
2020-07-15 16:09:05 +03:00
|
|
|
return profiles, nil
|
|
|
|
}
|
|
|
|
|
2020-10-09 20:24:37 +03:00
|
|
|
func (h contextCreateAWSHelper) chooseProfile(profiles []string) (string, error) {
|
2020-10-28 12:54:10 +03:00
|
|
|
options := []string{}
|
2020-10-09 20:24:37 +03:00
|
|
|
options = append(options, profiles...)
|
2020-07-15 16:09:05 +03:00
|
|
|
|
2020-10-09 20:24:37 +03:00
|
|
|
selected, err := h.user.Select("Select AWS Profile", options)
|
2020-07-15 16:09:05 +03:00
|
|
|
if err != nil {
|
|
|
|
if err == terminal.InterruptErr {
|
2021-06-14 17:26:14 +03:00
|
|
|
return "", api.ErrCanceled
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
|
|
|
return "", err
|
|
|
|
}
|
2020-10-09 20:24:37 +03:00
|
|
|
profile := options[selected]
|
2020-07-15 16:09:05 +03:00
|
|
|
return profile, nil
|
|
|
|
}
|
|
|
|
|
2020-10-30 19:42:57 +03:00
|
|
|
func getRegion(profile string) (string, error) {
|
2020-10-27 00:01:54 +03:00
|
|
|
if profile == "" {
|
|
|
|
profile = "default"
|
|
|
|
}
|
2020-10-09 20:24:37 +03:00
|
|
|
// only load ~/.aws/config
|
|
|
|
awsConfig := defaults.SharedConfigFilename()
|
|
|
|
configIni, err := ini.Load(awsConfig)
|
|
|
|
if err != nil {
|
|
|
|
if !os.IsNotExist(err) {
|
2020-10-30 19:42:57 +03:00
|
|
|
return "", err
|
2020-10-09 20:24:37 +03:00
|
|
|
}
|
|
|
|
configIni = ini.Empty()
|
|
|
|
}
|
2020-10-28 12:54:10 +03:00
|
|
|
|
2020-10-30 19:42:57 +03:00
|
|
|
getProfileRegion := func(p string) string {
|
2020-10-29 12:08:41 +03:00
|
|
|
r := ""
|
2020-10-28 12:54:10 +03:00
|
|
|
section, err := configIni.GetSection(p)
|
|
|
|
if err == nil {
|
|
|
|
reg, err := section.GetKey("region")
|
|
|
|
if err == nil {
|
|
|
|
r = reg.Value()
|
|
|
|
}
|
|
|
|
}
|
2020-10-30 19:42:57 +03:00
|
|
|
return r
|
2020-10-28 12:54:10 +03:00
|
|
|
}
|
2020-10-09 20:24:37 +03:00
|
|
|
if profile != "default" {
|
|
|
|
profile = fmt.Sprintf("profile %s", profile)
|
|
|
|
}
|
2020-10-30 19:42:57 +03:00
|
|
|
region := getProfileRegion(profile)
|
|
|
|
if region == "" {
|
|
|
|
region = getProfileRegion("default")
|
2020-11-02 18:24:35 +03:00
|
|
|
}
|
|
|
|
if region == "" {
|
|
|
|
// fallback to AWS default
|
|
|
|
region = "us-east-1"
|
2020-10-30 19:42:57 +03:00
|
|
|
}
|
|
|
|
return region, nil
|
2020-10-28 12:54:10 +03:00
|
|
|
}
|
|
|
|
|
2020-11-02 18:24:35 +03:00
|
|
|
func (h contextCreateAWSHelper) chooseRegion(opts *ContextParams) error {
|
|
|
|
regions, err := h.availableRegions(opts)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-10-09 20:24:37 +03:00
|
|
|
}
|
|
|
|
// promp user for region
|
2020-11-02 18:24:35 +03:00
|
|
|
selected, err := h.user.Select("Region", regions)
|
2020-10-09 20:24:37 +03:00
|
|
|
if err != nil {
|
2020-11-02 18:24:35 +03:00
|
|
|
return err
|
2020-10-09 20:24:37 +03:00
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
opts.Region = regions[selected]
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func listAvailableRegions(opts *ContextParams) ([]string, error) {
|
|
|
|
// Setup SDK with credentials, will also validate those
|
|
|
|
session, err := session.NewSessionWithOptions(session.Options{
|
|
|
|
Config: aws.Config{
|
|
|
|
Credentials: credentials.NewStaticCredentials(opts.AccessKey, opts.SecretKey, ""),
|
|
|
|
Region: aws.String("us-east-1"),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2020-10-09 20:24:37 +03:00
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
|
|
|
|
desc, err := ec2.New(session).DescribeRegions(&ec2.DescribeRegionsInput{})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var regions []string
|
|
|
|
for _, r := range desc.Regions {
|
|
|
|
regions = append(regions, aws.StringValue(r.RegionName))
|
|
|
|
}
|
|
|
|
return regions, nil
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h contextCreateAWSHelper) askCredentials() (string, string, error) {
|
2020-10-09 20:24:37 +03:00
|
|
|
accessKeyID, err := h.user.Input("AWS Access Key ID", "")
|
|
|
|
if err != nil {
|
|
|
|
return "", "", err
|
|
|
|
}
|
|
|
|
secretAccessKey, err := h.user.Password("Enter AWS Secret Access Key")
|
|
|
|
if err != nil {
|
|
|
|
return "", "", err
|
|
|
|
}
|
|
|
|
// validate access ID and password
|
|
|
|
if len(accessKeyID) < 3 || len(secretAccessKey) < 3 {
|
|
|
|
return "", "", fmt.Errorf("AWS Access/Secret Access Key must have more than 3 characters")
|
|
|
|
}
|
|
|
|
return accessKeyID, secretAccessKey, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func contains(values []string, value string) bool {
|
|
|
|
for _, v := range values {
|
|
|
|
if v == value {
|
|
|
|
return true
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
2020-10-09 20:24:37 +03:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func loadIniFile(path string, prefix bool) (map[string]ini.Section, error) {
|
|
|
|
profiles := map[string]ini.Section{}
|
|
|
|
credIni, err := ini.Load(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
for _, section := range credIni.Sections() {
|
|
|
|
if prefix && strings.HasPrefix(section.Name(), "profile ") {
|
|
|
|
profiles[section.Name()[len("profile "):]] = *section
|
|
|
|
} else if !prefix || section.Name() == "default" {
|
|
|
|
profiles[section.Name()] = *section
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
|
|
|
}
|
2020-10-09 20:24:37 +03:00
|
|
|
return profiles, nil
|
2020-07-15 16:09:05 +03:00
|
|
|
}
|
2020-11-02 18:24:35 +03:00
|
|
|
|
|
|
|
func getAWSConfigFile() string {
|
|
|
|
awsConfig, ok := os.LookupEnv("AWS_CONFIG_FILE")
|
|
|
|
if !ok {
|
|
|
|
awsConfig = defaults.SharedConfigFilename()
|
|
|
|
}
|
|
|
|
return awsConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
func getAWSCredentialsFile() string {
|
|
|
|
awsConfig, ok := os.LookupEnv("AWS_SHARED_CREDENTIALS_FILE")
|
|
|
|
if !ok {
|
|
|
|
awsConfig = defaults.SharedCredentialsFilename()
|
|
|
|
}
|
|
|
|
return awsConfig
|
|
|
|
}
|