Syntax error in policy, while running 'iam create-policy', but there is no syntax mistake

0

Hi,

Im trying to create "revoke" session policy for iam user using command aws iam create-policy --policy-name "revoke-session" --policy-document JSON.json And the content of the JSON.json is

{
    "Version": "2012-10-17",
    "Statement": {
      "Effect": "Deny",
      "Action": "*",
      "Resource": "*",
      "Condition": {"DateLessThan": {"aws:TokenIssueTime": "2022-03-23T15:30:00Z"}}
    }
}

But if i run the command it says An error occurred (MalformedPolicyDocument) when calling the CreatePolicy operation: Syntax errors in policy.

If i create exact same policy trough AWS console everything works!

So, im confused, what can be wrong?

1개 답변
1
수락된 답변

--policy-document, by default, takes the actual JSON content of the policy. To have the CLI read the content from a file, modify your command to use: --policy-document file://JSON.json.

(As issued, your command is passing JSON.json as the body of the policy document, which is why the service rejects it.)

profile pictureAWS
전문가
James_S
답변함 2년 전

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

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

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

관련 콘텐츠