From b444dec70477166deacaf0f73139e9700305b9aa Mon Sep 17 00:00:00 2001 From: Ian Mckay Date: Tue, 16 Jul 2024 21:24:55 -0700 Subject: [PATCH] use AWS_CONFIG_FILE if defined #80 --- iamlivecore/csm.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/iamlivecore/csm.go b/iamlivecore/csm.go index 4c4016eb..fce2d40c 100644 --- a/iamlivecore/csm.go +++ b/iamlivecore/csm.go @@ -65,9 +65,14 @@ func setConfigKey(filename, section, line string, unset bool) error { } func setINIConfigAndFileFlush() { + cfgfilepath := "~/.aws/config" + if os.Getenv("AWS_CONFIG_FILE") != "" { + cfgfilepath = os.Getenv("AWS_CONFIG_FILE") + } + // set ini if *setiniFlag { - cfgfile, err := homedir.Expand("~/.aws/config") + cfgfile, err := homedir.Expand(cfgfilepath) if err != nil { log.Fatal(err) } @@ -119,7 +124,7 @@ func setINIConfigAndFileFlush() { if s == syscall.SIGINT || s == syscall.SIGTERM || s == syscall.SIGQUIT { if *setiniFlag { // revert ini - cfgfile, err := homedir.Expand("~/.aws/config") // need to redeclare + cfgfile, err := homedir.Expand(cfgfilepath) // need to redeclare if err != nil { os.Exit(1) }