The Simplest Way to Make AWS Secrets Manager and Elasticsearch Work Like They Should
Teams pair aws secrets manager and elasticsearch to store and rotate search cluster passwords. Your app fetches credentials from the vault at runtime to run search queries. This setup keeps plain text passwords out of your source code and build files. It also lets security teams rotate cluster keys on a regular schedule. Developers do not need to update local files when a password changes. Instead, the app reads the latest secret value from the cloud vault. How aws secrets manager and elastic
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 aws secrets manager and elasticsearch to store and rotate search cluster passwords. Your app fetches credentials from the vault at runtime to run search queries.
This setup keeps plain text passwords out of your source code and build files. It also lets security teams rotate cluster keys on a regular schedule. Developers do not need to update local files when a password changes. Instead, the app reads the latest secret value from the cloud vault.
How aws secrets manager and elasticsearch share credentials
The workflow starts with identity roles in your cloud account. An app runs with an assigned cloud role that grants read permissions. This role allows the app to read one specific secret from the vault. The secret holds the username, password, or API key for the search cluster.
When the app starts up, it calls the vault API over a secure network. The vault checks the cloud role of the app before returning any data. If the role matches the policy, the vault sends back the cluster credentials. The app holds these credentials in memory and opens a session with the cluster.
Elasticsearch then checks the username and password against its own internal role store. Each cluster user maps to specific index permissions, such as read or write. To rotate keys, a serverless function updates both the cluster and the vault. This function generates a new secret, updates the search user, and saves the change.
Common failure modes and how to scope roles
Many teams still run into security gaps with this standard vault setup. The most common mistake is sharing one broad service account across many apps. If five apps read the same secret, you cannot tell who ran a bad query. Cluster logs only show the shared service account name, not the real caller.
AWS Secrets Manager + Elasticsearch Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Another common issue happens during password rotation. Apps often cache credentials in memory for hours or days to save API calls. When the vault rotates the password, the search cluster rejects the old cached key. The app then fails to run queries until someone restarts the service. Teams must write retry logic that fetches fresh secrets when a login fails.
Human access creates an even bigger risk for production search clusters. Engineers often pull the cluster password from the vault to debug a slow query. Once a person copies a secret to a laptop, the vault cannot track it. Broad cluster tokens also grant write access to every index by mistake. A single bad request can delete production records or expose sensitive customer data.
To fix these issues, scope both your vault policies and your cluster roles. Give each app its own cloud role and its own dedicated secret. Map each secret to a cluster user that only reads the required indexes. Restrict network routes so only trusted app subnets can reach the search cluster. Keep sensitive fields like emails, phone numbers, card numbers, and national IDs safe. Data masking rewrites matched fields in results before they reach the user screen.
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
How do apps handle cluster password rotation without downtime?
Use a dual-user rotation strategy in your vault setup. Two cluster users take turns staying active while apps switch to the newest secret.
Should engineers read production cluster passwords from the vault?
No, engineers should not copy raw passwords from the vault to their laptops. Human queries should go through a workflow that logs the user identity and request.
How should we scope cluster roles for different microservices?
Create a separate cluster role and vault secret for every single microservice. Grant each role read or write rules for only the indexes that service needs.
Related guides
In this post