Skip to content

When specifying a shared profile credentials in env vars are ignored, contrary to the documentation #1556

Closed as not planned
@AustinGomez

Description

Documentation

Describe the bug

We are trying to specify a shared profile config as follows:

config.LoadDefaultConfig(context.Background(), config.WithSharedConfigProfile("some-profile"))

The docs state here: "If you specify credentials in environment variables, the SDK always uses those credentials, no matter which profile you specify." However, if you specify a shared profile, the SDK uses the credentials in the specified shared config profile rather than the env vars.

After a quick investigation it looks like the bug comes from the following case statement. Maybe fallthrough was intended here.

err = resolveCredsFromProfile(ctx, cfg, envConfig, sharedConfig, other)

Expected behavior

The SDK should use the credentials in the environment variables.

Current behavior

The SDK uses the credentials in the aws Config file.

Steps to Reproduce

repro.go:

import "github.com/aws/aws-sdk-go-v2/config"

cfg, err := config.LoadDefaultConfig(context.Background(), config.WithSharedConfigProfile("some-profile"))
if err != nil {
	panic(err)
}
  1. Set credentials in AWS Config
  2. Run AWS_ACCESS_KEY=XXXXXXX AWS_SECRET_ACCESS_KEY=XXXXXXX AWS_SESSION_TOKEN=XXXXXXXX go run repro.go

The credentials are set in the env vars, but the ones in the Config file are used.

Possible Solution

Fix the control flow here if the intended behaviour is to have the env vars to take precedence, or update the docs otherwise.

AWS Go SDK version used

1.1.6

Compiler and Version used

go version go1.17.3 darwin/amd64

Operating System and version

macOS Big Sur 11.6.2

Metadata

Assignees

No one assigned

    Labels

    documentationThis is a problem with documentation.feature-requestA feature should be added or improved.p3This is a minor priority issuequeuedThis issues is on the AWS team's backlogsEffort estimation: small

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions