Skip to content

Commit

Permalink
Delete kms crypto key versions which are in any state other than (#6888
Browse files Browse the repository at this point in the history
…) (#13167)

DESTROYED or DESTROY_SCHEDULED

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Dec 2, 2022
1 parent 01fa964 commit 05c962d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/6888.txt
@@ -0,0 +1,3 @@
```release-note:bug
kms: fixed issues with deleting crypto key versions in states other than ENABLED
```
2 changes: 1 addition & 1 deletion google/kms_utils.go
Expand Up @@ -221,7 +221,7 @@ func clearCryptoKeyVersions(cryptoKeyId *kmsCryptoKeyId, userAgent string, confi

for _, version := range versionsResponse.CryptoKeyVersions {
// skip the versions that have been destroyed earlier
if version.State == "ENABLED" {
if version.State != "DESTROYED" && version.State != "DESTROY_SCHEDULED" {
request := &cloudkms.DestroyCryptoKeyVersionRequest{}
destroyCall := versionsClient.Destroy(version.Name, request)
if config.UserProjectOverride {
Expand Down

0 comments on commit 05c962d

Please sign in to comment.