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

[VAULT-2789] Enable AWS Auth to read credentials from named profiles #12602

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions builtin/credential/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (b *backend) getRawClientConfig(ctx context.Context, s logical.Storage, reg

credsConfig.AccessKey = config.AccessKey
credsConfig.SecretKey = config.SecretKey
credsConfig.Profile = config.Profile
maxRetries = config.MaxRetries
}

Expand Down
18 changes: 18 additions & 0 deletions builtin/credential/aws/path_config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func (b *backend) pathConfigClient() *framework.Path {
Description: "AWS Secret Access Key for the account used to make AWS API requests.",
},

"profile": {
Type: framework.TypeString,
Default: "default",
Description: "AWS Profile used to make AWS API requests.",
},

"endpoint": {
Type: framework.TypeString,
Default: "",
Expand Down Expand Up @@ -142,6 +148,7 @@ func (b *backend) pathConfigClientRead(ctx context.Context, req *logical.Request
return &logical.Response{
Data: map[string]interface{}{
"access_key": clientConfig.AccessKey,
"profile": clientConfig.Profile,
"endpoint": clientConfig.Endpoint,
"iam_endpoint": clientConfig.IAMEndpoint,
"sts_endpoint": clientConfig.STSEndpoint,
Expand Down Expand Up @@ -214,6 +221,16 @@ func (b *backend) pathConfigClientCreateUpdate(ctx context.Context, req *logical
configEntry.SecretKey = data.Get("secret_key").(string)
}

profileStr, ok := data.GetOk("profile")
if ok {
if configEntry.Profile != profileStr.(string) {
changedCreds = true
configEntry.Profile = profileStr.(string)
}
} else if req.Operation == logical.CreateOperation {
configEntry.Profile = data.Get("profile").(string)
}

endpointStr, ok := data.GetOk("endpoint")
if ok {
if configEntry.Endpoint != endpointStr.(string) {
Expand Down Expand Up @@ -338,6 +355,7 @@ type clientConfig struct {
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
Endpoint string `json:"endpoint"`
Profile string `json:"profile"`
IAMEndpoint string `json:"iam_endpoint"`
STSEndpoint string `json:"sts_endpoint"`
STSRegion string `json:"sts_region"`
Expand Down
3 changes: 3 additions & 0 deletions changelog/12602.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
aws/auth: Add Profile field to AWS Client Config to enable shared credentials between named profiles
```