diff --git a/cmd/konvoy-image-wrapper/cmd/wrapper.go b/cmd/konvoy-image-wrapper/cmd/wrapper.go index 5ba413501..b311885b8 100644 --- a/cmd/konvoy-image-wrapper/cmd/wrapper.go +++ b/cmd/konvoy-image-wrapper/cmd/wrapper.go @@ -20,6 +20,7 @@ import ( ) const ( + envAWSConfigFile = "AWS_CONFIG_FILE" //nolint:gosec // environment var set by user envAWSCredentialsFile = "AWS_SHARED_CREDENTIALS_FILE" //nolint:gosec // environment var set by user envAWSDefaultRegion = "AWS_DEFAULT_REGION" @@ -171,6 +172,7 @@ func (r *Runner) setAWSEnv() error { } } + // mount the aws credentials file _, found := os.LookupEnv(envAWSCredentialsFile) if !found { // fall-back to default location for aws credentials file @@ -180,6 +182,17 @@ func (r *Runner) setAWSEnv() error { return fmt.Errorf("unable to mount AWS credenttials file: %w", err) } + // mount the aws config file + _, found = os.LookupEnv(envAWSConfigFile) + if !found { + // fall-back to default location for aws config file + os.Setenv(envAWSConfigFile, filepath.Join(r.usr.HomeDir, ".aws", "config")) + } + + if err := r.mountFileEnv(envAWSConfigFile, filepath.Join(r.homeDir, ".aws", "config")); err != nil { + return fmt.Errorf("unable to mount AWS config file: %w", err) + } + if err := r.mountFileEnv(envAWSCABundle, ""); err != nil { return fmt.Errorf("unable to mount AWS CA bundle: %w", err) }