How to Configure Dify DynamoDB Credentials

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up dify dynamodb credentials by creating a scoped AWS role for your app. Next, you pass those role keys or session values into your Dify workflow settings. Many teams start by generating static IAM user keys with broad table permissions. This fast approach works in testing, but it exposes every table if a key leaks. Overly broad roles also let AI agents change or delete data by mistake. How dify dynamodb credentials work in native setups Dify runs workflows and agents that call extern

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up dify dynamodb credentials by creating a scoped AWS role for your app. Next, you pass those role keys or session values into your Dify workflow settings. Many teams start by generating static IAM user keys with broad table permissions. This fast approach works in testing, but it exposes every table if a key leaks. Overly broad roles also let AI agents change or delete data by mistake.

How dify dynamodb credentials work in native setups

Dify runs workflows and agents that call external tools and data stores during a task. When a workflow needs NoSQL data, it must log in with AWS before running queries. You can set up this link through custom tools or API nodes inside your workspace. The cloud provider checks the identity and role policy attached to the request.

Teams typically handle this setup in one of two ways. The first way uses static IAM keys stored as secret variables inside the tool settings. The workflow reads these secret variables and signs each request sent to the database. This method is simple to set up for an external or cloud-hosted app. Still, those static keys stay valid until an engineer rotates them by hand.

The second way uses runtime instance roles when you host the platform on AWS. You attach an IAM role directly to the compute instances or containers running your app. The underlying AWS SDK then fetches temporary session credentials on its own. You do not need to paste static keys into the workspace settings. Still, every workflow on that host shares the exact same role permissions.

What native IAM roles solve and what they leave open

Native AWS IAM roles do a great job of checking who can log in. You can write a policy that limits a role to specific tables and read actions. You can also block delete commands or table drops at the cloud account level. This setup keeps outside attackers from reading your data without a valid cloud identity.

Still, cloud IAM checks happen only when the session starts or the API call arrives. They decide which role can log in, not what individual queries do with sensitive items. Once a workflow has read permissions on a table, it can pull any attribute. If a table holds customer emails, phone numbers, or card numbers, the prompt receives them. Native cloud policies cannot rewrite matched fields in results before the model reads them.

Shared workspace keys also make auditing much harder for security teams. Cloud logs show that the app role ran a scan or put item call. They do not show which user, prompt, or agent step triggered that database action. When an agent runs a bad write command, you cannot hold a single step for human review. You have to choose between giving the whole app write permissions or blocking writes everywhere.

Ephemeral Credentials + DynamoDB Fine-Grained Access: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

How to scope permissions and manage secret rotation

Start by creating a dedicated IAM role just for your AI workflows. Never reuse a general backend role that already has broad permissions across your cloud account. Limit the policy to the exact table names that the specific workflow needs to read.

Split your read and write tools into separate identities whenever your setup allows it. Most agent tasks only need to look up state or fetch user context from items. Give those lookup tools a role that only allows item reads and queries. If a specific workflow step must update records, use a separate, tightly scoped role.

If you must use static keys, set a strict schedule to rotate them often. Store those keys in encrypted secret fields rather than plain text workflow inputs. Check your cloud audit logs each week to spot unusual scan rates or failed calls. Good hygiene around role scope reduces the blast radius when a prompt behaves badly.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Should I use static IAM keys or an instance role for Dify?

Use an instance or task role if you host the app inside your own AWS account. If you use a hosted service, create a dedicated IAM user with narrow table permissions.

How do I stop an AI agent from deleting DynamoDB items?

Remove item deletion and table management actions from the IAM policy attached to your credentials. Give the workflow role only the specific read or write actions required for the task.

Can native IAM policies hide sensitive fields inside a DynamoDB item?

IAM policies can block whole attributes by name, which often breaks app queries that expect them. They cannot mask values like emails or card numbers inside returned text on the fly.

The query runs. The emails stay hidden.