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

AWS - Use NewCredentialsConfig #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
33 changes: 21 additions & 12 deletions wrappers/awskms/awskms.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,27 @@ func (k *Wrapper) Client() kmsiface.KMSAPI {

// GetAwsKmsClient returns an instance of the KMS client.
func (k *Wrapper) GetAwsKmsClient() (*kms.KMS, error) {
credsConfig := &awsutil.CredentialsConfig{}

credsConfig.AccessKey = k.accessKey
credsConfig.SecretKey = k.secretKey
credsConfig.SessionToken = k.sessionToken
credsConfig.Filename = k.sharedCredsFilename
credsConfig.Profile = k.sharedCredsProfile
credsConfig.RoleARN = k.roleArn
credsConfig.RoleSessionName = k.roleSessionName
credsConfig.WebIdentityTokenFile = k.webIdentityTokenFile
credsConfig.Region = k.region
credsConfig.Logger = k.logger
credsConfig, err := awsutil.NewCredentialsConfig(
awsutil.WithLogger(k.logger),
awsutil.WithAccessKey(k.accessKey),
awsutil.WithSecretKey(k.secretKey),
awsutil.WithRoleArn(k.roleArn),
awsutil.WithRoleSessionName(k.roleSessionName),
awsutil.WithWebIdentityTokenFile(k.webIdentityTokenFile),
awsutil.WithRegion(k.region),
)
if err != nil {
return nil, err
}
if k.sessionToken != "" {
credsConfig.SessionToken = k.sessionToken
}
if k.sharedCredsFilename != "" {
credsConfig.Filename = k.sharedCredsFilename
}
if k.sharedCredsProfile != "" {
credsConfig.Profile = k.sharedCredsProfile
}

credsConfig.HTTPClient = cleanhttp.DefaultClient()

Expand Down