KMS で「The new key policy will not allow you to update the key policy in the future」になったときの対処方法

KMS で「The new key policy will not allow you to update the key policy in the future」になったときの対処方法

Clock Icon2024.10.10

困っていた内容

AWS マネジメントコンソールで KMS のキーポリシーを編集するとMalformedPolicyDocumentExceptionが表示されます。
AWS re:Postを参考に構文をチェックしましたが、問題ない認識です。
どうしたら良いでしょうか。

PutKeyPolicy リクエストが失敗しました
MalformedPolicyDocumentException - The new key policy will not allow you to update the key policy in the future.

AWS KMS MalformedPolicyDocumentException

どう対応すればいいの?

編集後のキーポリシーに、変更を行うユーザーの変更許可が含まれているか確認してください。

KMS キーが管理不能になるリスクを防ぐため、KMS では変更を行うユーザー(IAM ユーザー/ロール)が引き続きキーポリシーで変更を許可されているかチェックします。
例えば、IAM ユーザー A だけを許可するキーポリシーを、IAM ユーザー B を使って変更するリクエストはThe new key policy will not allow you to update the key policy in the futureで失敗します。

そのため、AWS マネジメントコンソールからキーポリシーを変更する場合は、変更を行うユーザーの変更権限を含めてください。

なお、この安全チェックはBypassPolicyLockoutSafetyChecktrueに設定するとスキップできます。

ただし、2024年10月時点で、AWS マネジメントコンソールからは設定ができないため、必要な場合はAWS CLI の put-key-policyからの変更も検討してください。

参考資料

The key policy must allow the calling principal to make a subsequent PutKeyPolicy request on the KMS key. This reduces the risk that the KMS key becomes unmanageable. For more information, see Default key policy in the AWS Key Management Service Developer Guide. (To omit this condition, set BypassPolicyLockoutSafetyCheck to true.)

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.