Troubleshooting¶
Common Issues¶
AccessDeniedException when encrypting or decrypting¶
Symptom:
Causes:
-
Role not in the key policy. Ensure the IAM role ARN is listed in
key_users,key_encrypt_only_users, orkey_decrypt_only_usersas appropriate. -
Encrypt-only role trying to decrypt. If the role is in
key_encrypt_only_users, it cannot decrypt. Move it tokey_usersif it needs both. -
Decrypt-only role trying to encrypt. If the role is in
key_decrypt_only_users, it cannot encrypt. Move it tokey_usersif it needs both. -
IAM policy denying KMS access. Even if the key policy allows the role, the role's IAM policy must also allow the KMS actions. Check for explicit
Denystatements. -
IAM propagation delay. After creating or modifying IAM roles, allow a few seconds for changes to propagate before attempting KMS operations.
Key policy is invalid¶
Symptom:
Cause: An ARN in one of the user lists is malformed or refers to a non-existent IAM role.
Fix: Verify all ARNs in key_users, key_encrypt_only_users, and key_decrypt_only_users are valid and the roles exist.
Key alias already exists¶
Symptom:
Cause: A KMS alias with the same name already exists in the account/region.
Fix: Use a different key_name or import the existing alias into your Terraform state.
Cannot delete key¶
Symptom: terraform destroy appears to hang or takes a long time.
Explanation: AWS KMS keys have a mandatory waiting period (7-30 days) before deletion. Terraform schedules the key for deletion and the destroy completes, but the key remains in PendingDeletion state in AWS until the waiting period expires.