Skip to content

Default authentication flow should fail if invalid profile name is passed #2058

@gdavison

Description

@gdavison

Describe the bug

When the default authentication flow is used with config.LoadDefaultConfig(), providing an invalid profile name, either with config.WithSharedConfigProfile() or by setting AWS_PROFILE, does not cause an error, but falls back to trying IMDS.

Previously reported as #1591, but the proposed fix did not resolve the issue

Expected Behavior

In the AWS CLI, I get

$ AWS_PROFILE=no-such-profile aws sts get-caller-identity

The config profile (no-such-profile) could not be found

The SDK should fail with a config.SharedConfigProfileNotExistError error, or at least have the option to do so.

Current Behavior

The AWS SDK falls back to calling IMDS

Reproduction Steps

cfg, err := config.LoadDefaultConfig(ctx)

and set AWS_PROFILE to an invalid profile name

or

cfg, err := config.LoadDefaultConfig(ctx, config.WithSharedConfigProfile("no-such-profile"))

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2 v1.13.0, github.com/aws/aws-sdk-go-v2/config v1.13.1

and

github.com/aws/aws-sdk-go-v2 v1.17.6, github.com/aws/aws-sdk-go-v2/config v1.18.18

Compiler and Version used

go version go1.20.2 darwin/arm64

Operating System and version

N/A

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions