The Simplest Way to Make Elasticsearch and GCP Secret Manager Work Like They Should
Pairing elasticsearch and gcp secret manager keeps your search cluster keys out of code. Your apps fetch fresh tokens from Google Cloud before they run search queries. This workflow stops teams from putting static passwords inside config files or build scripts. Instead, your cloud workload reads the stored key at runtime and logs in. How elasticsearch and gcp secret manager share keys and data The workflow starts with Google Cloud Identity and Access Management. Each app or service gets its
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.
Pairing elasticsearch and gcp secret manager keeps your search cluster keys out of code. Your apps fetch fresh tokens from Google Cloud before they run search queries.
This workflow stops teams from putting static passwords inside config files or build scripts. Instead, your cloud workload reads the stored key at runtime and logs in.
How elasticsearch and gcp secret manager share keys and data
The workflow starts with Google Cloud Identity and Access Management. Each app or service gets its own cloud identity. That identity holds a role that lets it read one specific secret. It cannot list or read other secrets in the project.
Inside the secret store, teams save the search cluster API key or user password. The secret store encrypts this data at rest and tracks every version. When the app starts, it calls the Google Cloud API to fetch the current version. The app keeps this key in memory and uses it to talk to the search cluster.
On the search side, the cluster checks the key against its own internal role rules. Those rules decide which indices the app can read or write. The secret store handles key delivery, while the search cluster controls index permissions. Both systems write audit logs so teams can track secret reads and index queries.
Common failure modes and how to scope roles
Many teams fail by sharing one cloud service account across multiple apps. When every app uses the same identity, any app can read every search key. If one app gets breached, the attacker gains broad permissions across your search indices. You should create one cloud service account for each app instead.
Broad search tokens cause a second major problem. Teams often store a superuser search key in the secret store for convenience. Even if the cloud role is tight, the app gets full admin rights on the cluster. Fix this by creating narrow search roles that only allow specific actions on named indices.
GCP Secret Manager + Elasticsearch Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Human access creates another gap. Engineers often fetch production keys from the secret store to run manual search queries. Once an engineer copies a key to a laptop, you lose track of who ran which query. Shared keys also make it hard to rotate secrets without breaking active work.
Unlogged queries and raw data exposure add more risk during debugging. Search indices often hold sensitive fields like emails, phone numbers, card numbers, or national IDs. You should scope network paths so clusters only accept traffic from approved cloud networks. You should also mask sensitive fields, which rewrites matched fields in results during queries.
Keeping rotated keys in sync across clusters
Storing a key in Google Cloud does not rotate the key inside your search cluster. If you add a new secret version in the cloud, the cluster still expects the old key. You must update the key in both places so your apps do not fail to log in.
A clean rotation process creates a new key in the search cluster first. Next, a script writes that new key as a fresh version in the secret store. Apps then fetch the latest version on their next restart or refresh cycle. Once all apps use the new key, you delete the old key from the search cluster.
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
Does GCP Secret Manager rotate Elasticsearch API keys on its own?
No, the secret store only sends alerts or triggers a cloud function on a schedule. You must run a function that calls the search cluster API to create a new key and save it.
Should apps fetch the search key on every single query?
No, fetching the secret on every search request adds delay and raises cloud API costs. Apps should load the key into memory at startup and refresh it on a set timer.
How do we restrict which indices a stored key can read?
You set index permissions inside the search cluster role when you create the API key. Google Cloud controls who can read the key, while the cluster controls what the key can do.
Related guides
In this post