From ffebfa46ebf15b1cb77eac0bf6adede1396f92c4 Mon Sep 17 00:00:00 2001 From: Brett Delle Grazie Date: Wed, 6 Nov 2024 21:54:48 +0100 Subject: [PATCH] fix: filter custom KMS in pending-replica-deletion Filter custom KMS keys in PendingReplicaDeletion as they've already been scheduled for deletion. Closes #408 --- resources/kms-key.go | 4 ++-- resources/kms-key_mock_test.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/resources/kms-key.go b/resources/kms-key.go index 0b5f46cb..af0c65f8 100644 --- a/resources/kms-key.go +++ b/resources/kms-key.go @@ -134,8 +134,8 @@ type KMSKey struct { } func (r *KMSKey) Filter() error { - if ptr.ToString(r.State) == kms.KeyStatePendingDeletion { - return fmt.Errorf("is already in PendingDeletion state") + if state := ptr.ToString(r.State); state == kms.KeyStatePendingDeletion || state == kms.KeyStatePendingReplicaDeletion { + return fmt.Errorf("is already in %v state", state) } if ptr.ToString(r.Manager) == kms.KeyManagerTypeAws { diff --git a/resources/kms-key_mock_test.go b/resources/kms-key_mock_test.go index a9fd1989..76a852cb 100644 --- a/resources/kms-key_mock_test.go +++ b/resources/kms-key_mock_test.go @@ -167,6 +167,12 @@ func Test_Mock_KMSKey_Filter(t *testing.T) { manager: kms.KeyManagerTypeCustomer, error: "is already in PendingDeletion state", }, + { + name: "pending-replica-deletion-key", + state: kms.KeyStatePendingReplicaDeletion, + manager: kms.KeyManagerTypeCustomer, + error: "is already in PendingReplicaDeletion state", + }, { name: "enabled-key", state: kms.KeyStateEnabled,