Skip to content

Commit

Permalink
Fix test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanratcliffe committed Aug 9, 2024
1 parent 06d1845 commit 9764ac0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 8 additions & 0 deletions sources/integration/kms/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package kms

import (
"context"
"errors"

"github.com/aws/aws-sdk-go-v2/service/kms"
"github.com/aws/aws-sdk-go-v2/service/kms/types"
"github.com/aws/smithy-go"
"github.com/overmindtech/aws-source/sources/integration"
)

Expand Down Expand Up @@ -32,6 +34,12 @@ func findActiveKeyIDByTags(ctx context.Context, client *kms.Client, additionalAt
tags, err := client.ListResourceTags(ctx, &kms.ListResourceTagsInput{
KeyId: keyListEntry.KeyId,
})
// There are some keys that even admins can't list the tags of. Not sure
// why but they seem to exist, we will ignore permissions errors here.
var awsErr *smithy.GenericAPIError
if errors.As(err, &awsErr) && awsErr.ErrorCode() == "AccessDeniedException" {
continue
}
if err != nil {
return nil, err
}
Expand Down
12 changes: 7 additions & 5 deletions sources/kms/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ func getFunc(ctx context.Context, client kmsClient, scope string, input *kms.Des
return nil, err
}

resourceTags, err := tags(ctx, client, *input.KeyId)
// Some keys can be accessed, but not their tags, even if you have full
// admin access. No clue how this is possible but seems to be an
// inconsistency in the AWS API. In this case, we will ignore the error and
// embed it in a tag so that you can see that they are missing
var resourceTags map[string]string
resourceTags, err = tags(ctx, client, *input.KeyId)
if err != nil {
return nil, &sdp.QueryError{
ErrorType: sdp.QueryError_NOTFOUND,
ErrorString: err.Error(),
}
resourceTags = sources.HandleTagsError(ctx, err)
}

item := &sdp.Item{
Expand Down

0 comments on commit 9764ac0

Please sign in to comment.