Skip to content

Commit

Permalink
fix: add missing .aws/config file mount (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatz authored May 6, 2024
1 parent 20706b8 commit efd89da
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/konvoy-image-wrapper/cmd/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit efd89da

Please sign in to comment.