Last active
April 21, 2022 10:13
-
-
Save devops-adeel/c80d6bc130a4419c15e86ed28f0a8184 to your computer and use it in GitHub Desktop.
Vault DR replication ACL following: https://learn.hashicorp.com/tutorials/vault/disaster-recovery?in=vault/day-one-raft#dr-operation-token-strategy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| locals { | |
| role_name = "failover-handler" | |
| } | |
| data "vault_policy_document" "default" { | |
| rule { | |
| path = "sys/replication/dr/secondary/promote" | |
| capabilities = ["update"] | |
| description = "Create and manage ACL policies" | |
| } | |
| rule { | |
| path = "sys/replication/dr/secondary/update-primary" | |
| capabilities = ["update"] | |
| description = "To update the primary to connect" | |
| } | |
| rule { | |
| path = "sys/storage/raft/autopilot/state" | |
| capabilities = ["read", "update"] | |
| description = "To read the current autopilot status" | |
| } | |
| } | |
| resource "vault_policy" "default" { | |
| name = "dr-secondary-promotion" | |
| policy = data.vault_policy_document.default.hcl | |
| } | |
| resource "vault_token_auth_backend_role" "default" { | |
| role_name = local.role_name | |
| allowed_policies = [vault_policy.default.name] | |
| orphan = true | |
| renewable = false | |
| token_type = "batch" | |
| } | |
| resource "vault_token" "default" { | |
| role_name = vault_token_auth_backend_role.default.name | |
| display_name = local.role_name | |
| ttl = "8h" | |
| } | |
| output "batch_token" { | |
| description = "create batch token" | |
| value = vault_token.default.client_token | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment