Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

MQTT wildcards instead of * wildcard used in examples #49

Closed
timmattison opened this issue Apr 15, 2021 · 4 comments
Closed

MQTT wildcards instead of * wildcard used in examples #49

timmattison opened this issue Apr 15, 2021 · 4 comments
Assignees
Labels
WIP Work in progress

Comments

@timmattison
Copy link
Contributor

The documentation says that + and # wildcards are treated as literal values and that customers should use * wildcards.

https://github.com/awsdocs/aws-iot-docs/blame/7b216b17d6c51a45fba81ab566dc9bd7d46181ea/developerguide/pub-sub-policy.md#L228

However, immediately above this is an example of a topic filter with a + in it and it says:

For devices registered as things in the AWS IoT Core registry, the following policy grants permission to connect to AWS IoT Core with the client ID that matches the thing name, and to subscribe to the topic filter some/+/topic only:

Is this intended?

@liunamz-aws liunamz-aws self-assigned this May 27, 2021
@liunamz-aws
Copy link
Contributor

liunamz-aws commented May 27, 2021

Hi, thanks for your feedback and apologies for the confusion.

I think the examples are correct. For topic wildcards, take a look at the following article:
https://docs.aws.amazon.com/iot/latest/developerguide/topics.html#topicfilters

@liunamz-aws
Copy link
Contributor

Any updates? I think what the note means is as follows:

  • Policies and MQTT interpret topic filter strings differently.
  • In MQTT subscription, + is treated as a wildcard for topic filter while in policies + is treated as a literal, not a wildcard.
  • Attempts to subscribe to topic filters pattern some/+/topic are considered some/{any string}/topic by MQTT but only some/+/topic by policies, and in policies these attempts fail and cause the client to disconnect.

Please let us know if you have any questions.

@liunamz-aws
Copy link
Contributor

liunamz-aws commented Jun 22, 2021

Hello @timmattison FYI.

I added a table to the topic you pointed out for more clarification. The content will be published to public soon.

Wildcard character Is MQTT wildcard character Example in MQTT Is AWS IoT Core policy wildcard character Example in AWS IoT Core policies for MQTT clients
# Yes some/# No N/A
+ Yes some/+/topic No N/A
* No N/A Yes topicfilter/some/*/topic

And these are the facts you might also be interested in when you pecify topicfilter in the Resource ARN for the iot:Subscribe action:

arn:aws:iot:region:account:topicfilter/test/topic subscribes to a single topic name
arn:aws:iot:region:account:topicfilter/test/* subscribes to multiple topic names (like test/# in MQTT)
arn:aws:iot:region:account:topicfilter/test/*/topic subscribes to multiple topic names (like test/+/topic in MQTT)

Hope this will help. Thanks!

@liunamz-aws liunamz-aws added the WIP Work in progress label Jun 22, 2021
@liunamz-aws
Copy link
Contributor

Hi, thanks again for your feedback.
We have updated this topic here.

Closing this issue for now as it has been addressed.
Please reopen it when you think is needed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
WIP Work in progress
Projects
None yet
Development

No branches or pull requests

2 participants