Skip to content

KMS key policy output in random ordered json document #9456

Closed
@AE86Trueno

Description

@AE86Trueno

Describe the bug

I initially noticed this behaviour when using Terraform.

Image
on the top part, i was expecting Terraform only updating the related resource
but what it show it also modifying unrelated resource and seem it swapping it around.

then further testings lead me to I realised it may be due to kms get-key-policy seem to return the policy document with random order which potentially the cause of this behaviour

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

the value returned from kms get-key-policy should always identical

Current Behavior

kms get-key-policy return random order value

Reproduction Steps

The test I did to see this behaviour i run aws cli multiple times to get the same policy output and save into file

aws kms get-key-policy --key-id {key_id} > test_key_xx.json

then i did diff the files gathered from json returned i can see its always random order

diff test_key_01.json test_key_02.json

This behaviour is different than when I check IAM policy
I tested to do the same on role's inline policy

"aws iam get-role-policy --role-name {rolename} --policy-name {policyname} > test_role_xx.json

diff the the json returned is always identical

diff test_role_01.json test_role_02.json

Possible Solution

No response

Additional Information/Context

No response

CLI version used

aws-cli/2.24.18 Python/3.12.9 Linux/5.15.167.4-microsoft-standard-WSL2 exe/x86_64.ubuntu.24

Environment details (OS name and version, etc.)

WSL version: 2.4.13.0 on Windows version: 10.0.19045.5737

Metadata

Metadata

Labels

bugThis issue is a bug.kmsp2This is a standard priority issueservice-apiThis issue is due to a problem in a service API, not the SDK implementation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions