Skip to content

Commit

Permalink
Config validation for kms
Browse files Browse the repository at this point in the history
  • Loading branch information
connorwstein committed Sep 18, 2024
1 parent b5f1c48 commit 188e993
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions integration-tests/deployment/evm_kmsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,20 @@ type KMS struct {
AwsProfileName string
}

func NewKMSClient(config KMS) KMSClient {
if config.KmsDeployerKeyId != "" && config.KmsDeployerKeyRegion != "" {
var awsSessionFn AwsSessionFn
if config.AwsProfileName != "" {
awsSessionFn = awsSessionFromProfileFn
} else {
awsSessionFn = awsSessionFromEnvVarsFn
}
return kms.New(awsSessionFn(config))
func NewKMSClient(config KMS) (KMSClient, error) {
if config.KmsDeployerKeyId == "" {
return nil, fmt.Errorf("KMS key ID is required")
}
if config.KmsDeployerKeyRegion == "" {
return nil, fmt.Errorf("KMS key region is required")
}
var awsSessionFn AwsSessionFn
if config.AwsProfileName != "" {
awsSessionFn = awsSessionFromProfileFn
} else {
awsSessionFn = awsSessionFromEnvVarsFn
}
return nil
return kms.New(awsSessionFn(config)), nil
}

type EVMKMSClient struct {
Expand Down

0 comments on commit 188e993

Please sign in to comment.