1

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

Michael - sqlbot
  • 169,571
  • 25
  • 353
  • 427
JC23
  • 1,248
  • 4
  • 18
  • 28
  • This probably won't help, but the IAM policy validator says your policy is valid. – scrowler Mar 04 '16 at 01:07
  • @RobbieAverill, apologies: I initially rolled back your edit, incorrectly thinking you had removed one extra `}` when in fact you didn't. The rollback is undone, your edit appears to have been correct as it was. – Michael - sqlbot Mar 04 '16 at 03:01
  • 1
    @Michael-sqlbot All good mate, have a good weekend – scrowler Mar 04 '16 at 03:38

1 Answers1

0

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.

JC23
  • 1,248
  • 4
  • 18
  • 28