Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
Return error from AWS session.NewSession() instead of panicking.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 532903972
  • Loading branch information
chuckx authored and copybara-github committed May 17, 2023
1 parent 9dfd3a9 commit 9500401
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions go/integration/awskms/aws_kms_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ func getKMS(uriPrefix string) (*kms.KMS, error) {
return nil, err
}

session := session.Must(session.NewSession(&aws.Config{
session, err := session.NewSession(&aws.Config{
Region: aws.String(r),
}))
})
if err != nil {
return nil, err
}

return kms.New(session), nil
}
Expand All @@ -166,10 +169,14 @@ func getKMSFromCredentialPath(uriPrefix string, credentialPath string) (*kms.KMS
// Fallback to load the credential path as .ini shared credentials.
creds = credentials.NewSharedCredentials(credentialPath, "default")
}
session := session.Must(session.NewSession(&aws.Config{

session, err := session.NewSession(&aws.Config{
Credentials: creds,
Region: aws.String(r),
}))
})
if err != nil {
return nil, err
}

return kms.New(session), nil
}
Expand Down

0 comments on commit 9500401

Please sign in to comment.