Skip to content

Commit

Permalink
Merge pull request #409 from bdellegrazie/fix/mutliregion-key-filter
Browse files Browse the repository at this point in the history
fix(kms-key): filter pending replica deletion state
  • Loading branch information
ekristen authored Nov 6, 2024
2 parents 1ba4abc + 86938c4 commit 3e7bff6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions resources/kms-key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions resources/kms-key_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3e7bff6

Please sign in to comment.