Page MenuHomeDevCentral

main.tf
No OneTemporary

# -------------------------------------------------------------
# Terraform :: OpenBao :: Modules :: App Credentials
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Module to create an AppRole and store its
# credentials in KV v2.
# License: BSD-2-Clause
# -------------------------------------------------------------
# -------------------------------------------------------------
# Create AppRole, fetch role_id and secret_id
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
resource "vault_approle_auth_backend_role" "this" {
backend = "approle"
role_name = var.role_name
secret_id_bound_cidrs = var.secret_id_bound_cidrs
token_policies = var.policies
token_ttl = var.token_ttl
token_max_ttl = var.token_max_ttl
}
data "vault_approle_auth_backend_role_id" "this" {
backend = "approle"
role_name = vault_approle_auth_backend_role.this.role_name
}
resource "vault_approle_auth_backend_role_secret_id" "this" {
backend = "approle"
role_name = vault_approle_auth_backend_role.this.role_name
lifecycle {
ignore_changes = [
secret_id,
]
}
}
# -------------------------------------------------------------
# Store AppRole credentials in KV v2
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
resource "vault_kv_secret_v2" "this" {
mount = var.kv_mount
name = var.kv_path
data_json = jsonencode({
role_id = data.vault_approle_auth_backend_role_id.this.role_id
secret_id = vault_approle_auth_backend_role_secret_id.this.secret_id
})
}

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 14, 20:34 (16 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4179913
Default Alt Text
main.tf (1 KB)

Event Timeline