JC23
JC23

Reputation: 1328

AWS client error (Malformed Policy Exception)

I am trying to create an AWS IoT Policy using the command: 'aws iot create-policy --policy-name "PubSubToAnyTopic" --policy-document file://path-to-your-policy-document'.

For some reason I can't get around the following: A client error (MalformedPolicyException) occurred when calling the CreatePolicy operation: Policy document is Malformed. I believe I've verified the path to the json file is correct with echo $(pwd)/file.json.

The AWS json code is below

{
"Version": "2012-10-17", 
"Statement": [{
    "Effect": "Allow",
    "Action": ["iot:*"],
    "Resource": ["*"]
}]
}

I've tried numerous changes (spacing, additional lines in between [ & {, etc..) but still can't create the policy. Tried vi & nano as well. Has anyone seen this error before? Thanks

Upvotes: 1

Views: 906

Answers (1)

JC23
JC23

Reputation: 1328

Removed the .json ending & it was accepted... strange because I initially tried it without the ending but it gave the same error?.?. I copied the code directly from the AWS site & pasted it (with right-click) into PuTTY so I don't think the editors (vi or nano) changed the code. For anyone else who comes across this error the command that worked for me: aws iot create-policy --policy-name "MyPolicyName" --policy-document file:///home/pi/my_policy_file. Good luck & thanks to @RobbieAverill & @Michael-sqlbot for giving this a look.

Upvotes: 0

Related Questions