greg
greg

Reputation: 99

Can't create and attach an AWS IoT Policy to my certificate

I'm following seemingly simple instructions on setting up Amazon IOT, and came to halt when trying to create policy.

Documentation says to create a policy with a sample JSON provided. I am following the instructions exactly:

I created a txt file called myTestPolicy.txt like this:

{

    "Version": "2016-3-3", 
    "Statement": [{
        "Effect": "Allow",
        "Action":["iot:*"],
        "Resource": ["*"]
    }]
}

placed in the local folder, but when I run the command:

aws iot create-policy --policy-name "PubSubToAnyTopic" --policy-document file://myTestPolicy.txt

I get an error:

A client error (MalformedPolicyException) occurred when calling the CreatePolicy operation: Policy document is Malformed

Totally stuck, googling yields no answers, can anyone help?

Upvotes: 0

Views: 532

Answers (2)

Fabien
Fabien

Reputation: 1

The version you selected is not recognized. If you try with "2012-10-17" it works fine (you can select either "2008-10-17" or "2012-10-17").

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

Upvotes: 0

greg
greg

Reputation: 99

OK, I opened a support ticket (paid) with Amazon, and tech confirmed that there is a bug in the documentation and/or the tools. He opened a ticket with engineering.

In the meantime, I was able to do this from AWS Dashboard (the IoT web UI allows you to create a policy and also do the other tasks that the (dysfunctional) CLI documentation is trying to guide you through.

Upvotes: 1

Related Questions