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

internal/config: remove UseLegacyWorkflow option #962

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
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
26 changes: 0 additions & 26 deletions aws_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,32 +1031,6 @@ aws_secret_access_key = DefaultSharedCredentialsSecretKey
aws_access_key_id = DefaultSharedCredentialsAccessKey
aws_secret_access_key = DefaultSharedCredentialsSecretKey

[SharedCredentialsProfile]
aws_access_key_id = ProfileSharedCredentialsAccessKey
aws_secret_access_key = ProfileSharedCredentialsSecretKey
`,
},
{
Config: &Config{
Profile: "SharedCredentialsProfile",
Region: "us-east-1",
UseLegacyWorkflow: true,
},
Description: "environment AWS_ACCESS_KEY_ID overrides config Profile in legacy workflow",
EnvironmentVariables: map[string]string{
"AWS_ACCESS_KEY_ID": servicemocks.MockEnvAccessKey,
"AWS_SECRET_ACCESS_KEY": servicemocks.MockEnvSecretKey,
},
ExpectedCredentialsValue: mockdata.MockEnvCredentials,
ExpectedRegion: "us-east-1",
MockStsEndpoints: []*servicemocks.MockEndpoint{
servicemocks.MockStsGetCallerIdentityValidEndpoint,
},
SharedCredentialsFile: `
[default]
aws_access_key_id = DefaultSharedCredentialsAccessKey
aws_secret_access_key = DefaultSharedCredentialsSecretKey

[SharedCredentialsProfile]
aws_access_key_id = ProfileSharedCredentialsAccessKey
aws_secret_access_key = ProfileSharedCredentialsSecretKey
Expand Down
14 changes: 3 additions & 11 deletions credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,9 @@ func getCredentialsProvider(ctx context.Context, c *Config) (aws.CredentialsProv
}

if c.Profile != "" && os.Getenv("AWS_ACCESS_KEY_ID") != "" && os.Getenv("AWS_SECRET_ACCESS_KEY") != "" {
if c.UseLegacyWorkflow {
diags.AddWarning("Configuration conflict overridden",
`A Profile was specified along with the environment variables "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY". `+
`The legacy workflow is enabled, so the Profile will be ignored in favor of the environment variable credentials. `+
`This behavior may be removed in the future.`)
c.Profile = ""
} else {
diags.AddWarning("Configuration conflict detected",
`A Profile was specified along with the environment variables "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY". `+
`The Profile is now used instead of the environment variable credentials. This may lead to unexpected behavior.`)
}
diags.AddWarning("Configuration conflict detected",
`A Profile was specified along with the environment variables "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY". `+
`The Profile is now used instead of the environment variable credentials. This may lead to unexpected behavior.`)
}

if profile := c.Profile; profile != "" {
Expand Down
1 change: 0 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ type Config struct {
TokenBucketRateLimiterCapacity int
UseDualStackEndpoint bool
UseFIPSEndpoint bool
UseLegacyWorkflow bool
UserAgent UserAgentProducts
}

Expand Down