- Newest
- Most votes
- Most comments
Hi. At least in regards to the Subscribe
action, you're using an incorrect resource. It should be topicfilter
, not topic
:
https://docs.aws.amazon.com/iot/latest/developerguide/iot-action-resources.html
Good morning, I have a similar problem. I want to apply a MQTT policy that grants the IoT thing access to certain topic. For example, assuming that the thing name is 0R281, I would like a policy that allows the thing to publish only in a topic with the following name xgate/0R281/data
I created a policy structured like this { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:Connect", "Resource": "arn:aws:iot:eu-west-1:<acc>:client/${iot:Connection.Thing.ThingName}" }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:eu-west-1:<acc>:topicfilter/xgate/${iot:Connection.Thing.ThingName}/data" }, { "Effect": "Allow", "Action": "iot:Publish", "Resource": "arn:aws:iot:eu-west-1:<acc>:topic/xgate/${iot:Connection.Thing.ThingName}/data" } ] }
but it does not work. Trying with a policy made like this obviously works,
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:", "Resource": "" } ] }
I don't understand where the mistake is
Relevant content
- asked 5 months ago
- Accepted Answerasked 4 months ago
- asked 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
Try this. It will allow you to publish and subscribe to a topic with the thingname. I never had any luck when adding suffixes after the thingname.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:Connect", "Resource": "arn:aws:iot:eu-west-1:<ACC>:client/${iot:Connection.Thing.ThingName}" }, { "Effect": "Allow", "Action": "iot:Publish", "Resource": "arn:aws:iot:eu-west-1:<ACC>:topic/xgate/${iot:Connection.Thing.ThingName}" }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:eu-west-1:<ACC>:topicfilter/xgate/${iot:Connection.Thing.ThingName}" }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": "arn:aws:iot:eu-west-1:<ACC>:topic/xgate/${iot:Connection.Thing.ThingName}" } ] }