---
title: "Comment by Jash Sayani on \"Lock Down DynamoDB with IAM Policy Conditions\" | Hashnode"
description: "Interesting, so you need to prepend the primary key with auth credentials youself, and include it in queries. I assumed DynamoDB does it in the background when"
url: "https://hashnode.com/posts/lock-down-dynamodb-with-iam-policy-conditions/6006e59c094f2b30301dd952/comment/61c97b5d1de80a7fb227ffb1"
---

[Discussion](https://hashnode.com/posts/lock-down-dynamodb-with-iam-policy-conditions/6006e59c094f2b30301dd952)

Comment [Lock Down DynamoDB with IAM Policy Conditions](https://hashnode.com/posts/lock-down-dynamodb-with-iam-policy-conditions/6006e59c094f2b30301dd952)

[Jash Sayani](https://hashnode.com/@jashsayani)

[Dec 27, 2021](https://hashnode.com/posts/lock-down-dynamodb-with-iam-policy-conditions/6006e59c094f2b30301dd952/comment/61c97b5d1de80a7fb227ffb1)

Interesting, so you need to prepend the primary key with auth credentials youself, and include it in queries. I assumed DynamoDB does it in the background when auth token is provided.

[Matt Martz](https://hashnode.com/@martzmakes)

[Dec 27, 2021](https://hashnode.com/posts/lock-down-dynamodb-with-iam-policy-conditions/6006e59c094f2b30301dd952/comment/61c97b5d1de80a7fb227ffb1#reply-61ca35c98787d923bc663318)

No, there aren't any credentials in the DDB key. The IAM policy that the Lambda uses to get read access to DDB includes a constraint that restricts what it can see. In the example above you can see the PK is just simply Tenant#1. The JWT includes the tenant number so the condition in the policy:

```
'dynamodb:LeadingKeys': [`Tenant#${who}`],
```

means that when the lambda is invoked where "who" is 1... they'd only see the Tenant#1 records.
