mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
aws: pass cancelable context with aws calls (#19365)
* auth/aws: use cancelable context with aws calls * secrets/aws: use cancelable context with aws calls
This commit is contained in:
@@ -100,7 +100,7 @@ func (b *backend) pathConfigRotateRootUpdate(ctx context.Context, req *logical.R
|
||||
// Get the current user's name since it's required to create an access key.
|
||||
// Empty input means get the current user.
|
||||
var getUserInput iam.GetUserInput
|
||||
getUserRes, err := iamClient.GetUser(&getUserInput)
|
||||
getUserRes, err := iamClient.GetUserWithContext(ctx, &getUserInput)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error calling GetUser: %w", err)
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func (b *backend) pathConfigRotateRootUpdate(ctx context.Context, req *logical.R
|
||||
createAccessKeyInput := iam.CreateAccessKeyInput{
|
||||
UserName: getUserRes.User.UserName,
|
||||
}
|
||||
createAccessKeyRes, err := iamClient.CreateAccessKey(&createAccessKeyInput)
|
||||
createAccessKeyRes, err := iamClient.CreateAccessKeyWithContext(ctx, &createAccessKeyInput)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error calling CreateAccessKey: %w", err)
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func (b *backend) pathConfigRotateRootUpdate(ctx context.Context, req *logical.R
|
||||
AccessKeyId: createAccessKeyRes.AccessKey.AccessKeyId,
|
||||
UserName: getUserRes.User.UserName,
|
||||
}
|
||||
if _, err := iamClient.DeleteAccessKey(&deleteAccessKeyInput); err != nil {
|
||||
if _, err := iamClient.DeleteAccessKeyWithContext(ctx, &deleteAccessKeyInput); err != nil {
|
||||
// Include this error in the errs returned by this method.
|
||||
errs = multierror.Append(errs, fmt.Errorf("error deleting newly created but unstored access key ID %s: %s", *createAccessKeyRes.AccessKey.AccessKeyId, err))
|
||||
}
|
||||
@@ -179,7 +179,7 @@ func (b *backend) pathConfigRotateRootUpdate(ctx context.Context, req *logical.R
|
||||
AccessKeyId: aws.String(oldAccessKey),
|
||||
UserName: getUserRes.User.UserName,
|
||||
}
|
||||
if _, err = iamClient.DeleteAccessKey(&deleteAccessKeyInput); err != nil {
|
||||
if _, err = iamClient.DeleteAccessKeyWithContext(ctx, &deleteAccessKeyInput); err != nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("error deleting old access key ID %s: %w", oldAccessKey, err))
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user