Last active
July 13, 2022 11:32
-
-
Save fvoges/cb903d225ca53cbdc9cbb080fb4ca048 to your computer and use it in GitHub Desktop.
Vault application namespace example
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 { | |
app_ns = "app1" | |
member_group_ids = [] | |
} | |
resource "vault_namespace" "default" { | |
path = local.app_ns | |
} | |
provider "vault" { | |
alias = "app_ns" | |
namespace = local.app_ns | |
} | |
resource "vault_mount" "kvv2" { | |
path = "secret" | |
type = "kv" | |
options = { version = "2" } | |
description = "KV Version 2 secret engine mount" | |
namespace = local.app_ns | |
} | |
resource "vault_kv_secret_backend_v2" "config" { | |
mount = vault_mount.kvv2.path | |
max_versions = 5 | |
provider = vault.app_ns # thies resource doesn't support the namespace argument yet (provider v3.7.0) | |
} | |
data "vault_policy_document" "app1_secrets" { | |
rule { | |
path = format("%s/secret/*", local.app_ns) | |
capabilities = ["create", "read", "update", "delete", "list"] | |
description = "allow all on secrets" | |
} | |
} | |
resource "vault_policy" "app1_secrets" { | |
name = "example_policy" | |
policy = data.vault_policy_document.app1_secrets.hcl | |
} | |
resource "vault_identity_group" "internal" { | |
name = local.app_ns | |
type = "internal" | |
external_member_entity_ids = false | |
member_group_ids = local.member_group_ids | |
policies = vault_policy.app1_secrets.name | |
} | |
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
terraform { | |
required_providers { | |
vault = { | |
source = "hashicorp/vault" | |
version = ">= 3.7.0, < 4.0.0" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment