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

fix: skip kms keys if describe is disallowed #1248

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 16 additions & 0 deletions resources/kms-keys.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package resources

import (
"errors"
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kms"
"github.com/sirupsen/logrus"

"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

Expand All @@ -32,6 +36,12 @@ func ListKMSKeys(sess *session.Session) ([]Resource, error) {
KeyId: key.KeyId,
})
if err != nil {
var ae awserr.Error
if errors.As(err, &ae) && ae.Code() == "AccessDeniedException" {
logrus.Warnf("access denied when running DescribeKey on %s, skipping", *key.KeyId)
continue
}

innerErr = err
return false
}
Expand All @@ -55,6 +65,12 @@ func ListKMSKeys(sess *session.Session) ([]Resource, error) {
KeyId: key.KeyId,
})
if err != nil {
var ae awserr.Error
if errors.As(err, &ae) && ae.Code() == "AccessDeniedException" {
logrus.Warnf("access denied when running ListResourceTags on %s, skipping", *key.KeyId)
continue
}

innerErr = err
return false
}
Expand Down