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

fix: aws kms health check #308

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
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
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