How to Configure Elasticsearch Replication User

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up an elasticsearch replication user, create dedicated accounts on both the leader and follower clusters. Assign read permissions on the leader cluster and write permissions on the follower cluster. Many teams rush this step and use shared admin accounts to move data between clusters. Broad roles expose every index if an account key leaks or an engineer makes a mistake. Scoped accounts limit what each cluster can read or change during sync tasks. How an elasticsearch replication user wo

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.

To set up an elasticsearch replication user, create dedicated accounts on both the leader and follower clusters. Assign read permissions on the leader cluster and write permissions on the follower cluster. Many teams rush this step and use shared admin accounts to move data between clusters. Broad roles expose every index if an account key leaks or an engineer makes a mistake. Scoped accounts limit what each cluster can read or change during sync tasks.

How an elasticsearch replication user works

Cross-cluster replication pulls data from a leader cluster to a follower cluster. The follower cluster initiates the request and asks the leader for recent index changes. So, the identity used by the follower needs specific rights on the remote leader. First, you define a role on the leader cluster that grants read rights on target indices. You also add cluster privileges so the follower can check cluster state and remote info. Next, you create a role on the follower cluster that allows index writes and replication tasks. You then bind these roles to dedicated service accounts on each side. If your clusters use mutual TLS, the follower presents a certificate that maps to the leader role. If you use token or password auth, the follower stores credentials to talk to the leader. Separating leader read roles from follower write roles keeps the sync path one-way. The follower can pull shards from the leader, but it cannot delete leader data.

Where native replication roles fall short

Native cluster roles control which service account can start a sync task or read an index. They work well for machine-to-machine sync between two backend clusters. Still, engineers still need to log in to set up, pause, or fix broken followers. Teams often share the same high-privilege account used for setup to debug sync errors. Once an engineer logs in with a cluster role, the cluster trusts every request in that session. Native roles decide who can log in, not what individual queries do in flight. If a synced index holds emails, phone numbers, or card numbers, anyone with read rights gets raw data. Native permissions also cannot require a peer review before someone drops a follower index. When five engineers share one admin role, cluster audit logs cannot show who ran a bad command. You need query-level checks and field masking to protect data during human debugging sessions.

Best practices for cross-cluster roles

Keep human debugging accounts separate from the machine accounts that run background sync tasks. Restrict the leader read role to exact index names rather than wildcard patterns. Wildcard grants often pull sensitive new indices into a lower-security follower cluster by mistake. Rotate the credentials or certificates used by the follower cluster on a fixed schedule. Review cluster role bindings every quarter to remove old test indices from the sync list. When engineers must inspect follower data, apply data masking to rewrite emails and card numbers in results. This keeps sensitive fields safe while teams fix shard or mapping issues.

User Provisioning (SCIM) + Elasticsearch Security: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

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 sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses 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 the leader cluster push data to the follower cluster?

No, cross-cluster replication uses a pull model where the follower requests updates from the leader. Because of this, the follower holds the credentials needed to read from the leader cluster.

Can one account manage replication on both clusters?

You can use the same username on both sides, but their roles should differ. The leader account only needs read access, while the follower account needs write access.

How do I protect sensitive fields in replicated indices?

Scope the leader role to specific indices and exclude private system indices from replication. For human queries on either cluster, use dynamic masking to rewrite emails or phone numbers in results.

The query runs. The emails stay hidden.