Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #308 from fqutishat/update
Browse files Browse the repository at this point in the history
fix: aws kms health check
  • Loading branch information
fqutishat authored May 26, 2022
2 parents bd144f0 + de0fe31 commit d46e46e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pkg/aws/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ func (s *Service) Get(keyID string) (interface{}, error) {

// HealthCheck check kms.
func (s *Service) HealthCheck() error {
_, err := s.client.DescribeKey(&kms.DescribeKeyInput{KeyId: &s.healthCheckKeyID})
keyID, err := getKeyID(s.healthCheckKeyID)
if err != nil {
return err
}

_, err = s.client.DescribeKey(&kms.DescribeKeyInput{KeyId: &keyID})
if err != nil {
return err
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/aws/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ func TestHealthCheck(t *testing.T) {
})
require.NoError(t, err)

svc := New(awsSession, &mockMetrics{}, "")
svc := New(awsSession, &mockMetrics{},
"aws-kms://arn:aws:kms:ca-central-1:111122223333:key/800d5768-3fd7-4edd-a4b8-4c81c3e4c147")

svc.client = &mockAWSClient{describeKeyFunc: func(input *kms.DescribeKeyInput) (*kms.DescribeKeyOutput, error) {
return &kms.DescribeKeyOutput{}, nil
Expand All @@ -112,7 +113,8 @@ func TestHealthCheck(t *testing.T) {
})
require.NoError(t, err)

svc := New(awsSession, &mockMetrics{}, "")
svc := New(awsSession, &mockMetrics{},
"aws-kms://arn:aws:kms:ca-central-1:111122223333:key/800d5768-3fd7-4edd-a4b8-4c81c3e4c147")

svc.client = &mockAWSClient{describeKeyFunc: func(input *kms.DescribeKeyInput) (*kms.DescribeKeyOutput, error) {
return nil, fmt.Errorf("failed to list keys")
Expand Down

0 comments on commit d46e46e

Please sign in to comment.