Skip to content

Policy resource only works with *

0

Hello, I have an ESP32 connected to AWS IOT core. All works. But it only works if I enter "" in the Policy resource of iot:connect, iot:publish, iot:receive and iot:subscribe. It seems to me this is not as safe as it would be if I entered the correct values for "arn:iot:[location]:[userid]:topic/". However that doesnt work. Question 1 is: is it unsafe to put "" in the policy resource? Question 2 is: what exactly do I have to put in there that it works?

asked 2 years ago186 views

2 Answers
2

For all AWS services, the resources and condition keys supported by each permission specification are documented centrally, in uniform syntax, in the AWS Service Authorization Reference. For iot, the relevant page is here: https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html

The first table on the page lists all the actions, such as "Connect" and "Publish", for which permissions can be specified. There's one or more table rows for each action and action/resource combination, along with the supported condition keys for the action or combination.

For example, the iot:Publish action supports the "topic" resource specification, but iot:Connect doesn't, since it isn't related to a specific topic but to a client. To specify the correct resource types for the permissions, I'd suggest writing three separate IAM policy statements to match the action/resource combinations. One policy statement would be for the iot:Publish, andiot:Receive actions, combined with the topic ARN as the resource. A second policy statement would allow iot:Connect, which only supports either a client ARN or the * wildcard as the resource. The third statement would be for iot:Subscribe, which accepts a topicfilter type of resource ARN.

The specific formats for the resource ARNs, such as "topicfilter", are described in another table after the actions table.

EXPERT

answered 2 years ago

AWS
EXPERT

reviewed 2 years ago

0

Hi there, at a high level AWS IoT Core policy security best practices focus on implementing the principle of least privilege by specifying exact permissions for each device. Instead of using overly permissive wildcards ("*"), policies should use specific client IDs, structured topic hierarchies (e.g., company/device-type/device-id/data-type), and policy variables like ${iot:ClientId}. Devices should only have permission to publish/subscribe to their own topics, and policies should include conditions to enforce additional security controls like rate limiting and thing attachment verification. Regular policy audits, monitoring of failed policy evaluations, proper certificate management, and maintaining version control of policies are essential practices. The goal is to ensure each device has exactly the permissions it needs to function - no more, no less - while maintaining a clear and manageable security structure.

You can refer to: https://docs.aws.amazon.com/wellarchitected/latest/iot-lens-checklist/best-practice-1-2.html

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.