Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D2IQ-100548: add missing .aws/config file mount - main #1064

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading