The Simplest Way to Make Dynamodb and Elasticsearch Work Like They Should
Teams pair dynamodb and elasticsearch to run fast transactions alongside full-text search. Your app writes records to the table and streams changes to the search index. This pattern splits the workload between two distinct systems. The primary table handles fast key lookups and high write volume. The search cluster runs complex filters, text queries, and aggregations. Each engine does the exact job it was built to do. How data and roles flow between dynamodb and elasticsearch Data moves from
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.
Teams pair dynamodb and elasticsearch to run fast transactions alongside full-text search. Your app writes records to the table and streams changes to the search index.
This pattern splits the workload between two distinct systems. The primary table handles fast key lookups and high write volume. The search cluster runs complex filters, text queries, and aggregations. Each engine does the exact job it was built to do.
How data and roles flow between dynamodb and elasticsearch
Data moves from the primary table to the search cluster through a change stream. Every insert, update, or delete writes an event to that ordered stream. A worker function or ingestion pipeline reads each batch of events in order. That worker transforms the record into a JSON document and sends it to the index.
Identity rules govern every step of this pipeline. The ingestion worker uses a dedicated role to read records from the table stream. That role only allows stream reads on one specific table resource. Next, the worker signs its write requests to the search cluster. The search cluster checks those permissions and allows index updates on the right path.
Sensitive fields often travel through this exact pipeline. Customer records might contain emails, phone numbers, card numbers, or national IDs. Teams must track where those fields land when documents reach the search cluster. Good pipeline design rewrites or drops sensitive fields before indexing when search does not need them.
Common failure modes and how to scope permissions
Many teams start with a single shared service account for the whole pipeline. That account often holds broad read and write permissions across every table and index. If an attacker steals that static key, they can read all data in both stores. Shared credentials also make audit logs hard to read during an incident.
Unlogged manual queries create another major blind spot for security teams. Engineers often log in to the search cluster or query tables to fix sync bugs. When everyone uses the same admin role, logs show what ran but not who ran it. Data masking is also missing when engineers run raw queries against production indices.
Elasticsearch Security + DynamoDB Fine-Grained Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can fix these risks by scoping roles and network paths tightly. Give each sync worker a narrow role that only reads one table stream. Restrict its write permissions to a single index pattern on the search cluster. Place both systems in private network subnets and block public traffic.
Poison pill records can also stall the change stream if a document fails validation. Set up a dead-letter queue to catch failed events so the stream keeps moving. Alert your team when that queue grows so they can inspect and replay bad records.
Keeping human queries safe across both data stores
Automated sync workers are only half of the security picture. Developers and support engineers also run direct queries to check sync lag and inspect documents. Giving humans static database keys or long-lived search passwords creates permanent risk.
Map every human session to an individual identity from your identity provider. Grant read-only roles for routine debugging and require approval for write sessions. Rewrite matched fields like emails or card numbers in query results to protect sensitive data. Log every query with the user identity and timestamp for clean audits.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Why do teams run both data stores instead of just one?
Key-value tables offer fast, predictable writes and single-item reads at scale. Search clusters handle fuzzy text queries, multi-field filters, and real-time aggregations much better.
How do you handle failed updates between the stream and the search index?
Route failed records to a dead-letter queue instead of blocking the entire stream. Your team can then fix the mapping issue and replay those stored events safely.
How should teams protect sensitive fields like emails or card numbers in search?
Strip fields you never search before indexing, and apply dynamic masking on query results. Masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs.
Related guides
In this post