MalformedPolicyDocumentException null being thrown putting policy on CMK

0

I have created and IAM User and a CMK. When trying to put the policy on the CMK it is throwing a MalformedPolicyDocumentException null error but does NOT define WHAT the malformation is, just a generic Policy is not syntactically or semantically correct.

I have verified (via jslint) that the json I'm passing to the policy parameter is properly formatted and valid json.

I have eliminated this as a timing issue by creating the User and CMK and then waiting and trying to apply the key 30 min later.

Here is the code and the policy document (redacted of specific ARN data):

CODE:

    PutKeyPolicyRequest putKeyPolicyRequest = PutKeyPolicyRequest.builder()  

            .keyId(targetKeyId)  
            .policy(masterKeyPolicyDocument) //Add JSON document below  
            .policyName("default")  
            .bypassPolicyLockoutSafetyCheck(true)  
            .build();  


    PutKeyPolicyResponse putCreatePolicyResponse = kmsClient.putKeyPolicy(putKeyPolicyRequest); //Error thrown here  

EDITED: Found solution.

It would be REALLY NICE if in the developer guide you published or at least referenced the POLICY schema from the IAM policy in the KMS policy section versus assuming that structure was already known.

Edited by: qdpaul on Aug 10, 2020 10:16 AM

qdpaul
질문됨 4년 전371회 조회
1개 답변
0

After finding the Policy Schema definitions in the IAM user policy guide was able to create semantically correct policy json.

qdpaul
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠