---
title: "Discussion on \"Lock Down DynamoDB with IAM Policy Conditions\" | Hashnode"
description: "Discussion on \"Lock Down DynamoDB with IAM Policy Conditions\". At work we've begun exploring the use of IAM policy conditions to limit access to items in our DynamoDB Tables.  This gives a much more specific level of control on who can retrieve what data.  Before a lambda executes, a separate process generates a..."
url: "https://hashnode.com/posts/lock-down-dynamodb-with-iam-policy-conditions/6006e59c094f2b30301dd952"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Lock Down DynamoDB with IAM Policy Conditions](https://martzmakes.com/lock-down-dynamodb-with-iam-policy-conditions?utm_source=hashnode&utm_medium=feed)

At work we've begun exploring the use of IAM policy conditions to limit access to items in our DynamoDB Tables. This gives a much more specific level of control on who can retrieve what data. Before a lambda executes, a separate process generates a...

Jan 19, 2021 · 9 min read · martzmakes.com  
Read the article

-   [#aws](https://hashnode.com/tag/aws)
-   [#dynamodb](https://hashnode.com/tag/dynamodb)
-   [#security](https://hashnode.com/tag/security)
-   [#aws-cdk](https://hashnode.com/tag/aws-cdk)

## Written by

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

@martzmakes · Burke, VA

  
[View profile](https://hashnode.com/@martzmakes)

AWS Community Builder

I'm an AWS Community Builder and a Principal Software Architect I love all things CDK, Event Driven Architecture and Serverless

## Responses 1

Markdown supported · ⌘↵ to post

[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.
