- Newest
- Most votes
- Most comments
The Token Exchange Service uses the AWS IoT Credential provider to obtain the credentials. From the developer guide, there are three policy variables that can be used:
For each AWS service that you want to call, attach an access policy to the role. The credentials provider supports the following policy variables:
credentials-iot:ThingName
credentials-iot:ThingTypeName
credentials-iot:AwsCertificateId
Which are then evaluated and provided to IAM only. E.g., These three variables work for IAM policies only, not AWS IoT Core policies.
So for your case of "arn:aws:s3:::devices/${iot:Connection.Thing.ThingName}/*", try using the following as the resource: "arn:aws:s3:::devices/${credentials-iot:ThingName}/*".
Hi Phil. iot:Connection.Thing.ThingName is only available in IoT policies. And only for actions performed over MQTT. So it can't be used in IAM policies.
Can you perhaps use presigned URLs instead?
UPDATE: Gavin's answer is better.
Relevant content
- AWS OFFICIALUpdated 6 months ago

This works perfectly! Thank you. I feel like it should be a more prominent solution in the documentation - having to only manage one policy makes managing the devices at scale very easy! I got this working directly from the IoT certificates but not yet tested through GG and the TES
Does the GG Token Exchange Service pass the
x-amzn-iot-thingnameheader when it makes the request? So I can rely on the fact thecredentials-iot:ThingNamewill be availabe?Glad it's working Phil. As for thingName, I'm pretty sure it does as that's a parameter to the TES cloud helper. We'll pass along your comment to make more visible in the documentation too.