-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
blockchain_integration/pi_network/CloudNexus/secrets/vault/vault.tf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
provider "vault" { | ||
address = "https://vault.pi-network.com:8200" | ||
} | ||
|
||
# Create a Vault namespace for the Pi Network | ||
resource "vault_namespace" "pi_network" { | ||
path = "pi-network" | ||
} | ||
|
||
# Create a Vault policy for the Pi Network | ||
resource "vault_policy" "pi_network" { | ||
name = "pi-network-policy" | ||
policy = <<EOF | ||
path "pi-network/*" { | ||
capabilities = ["create", "read", "update", "delete", "list"] | ||
} | ||
path "pi-network/secret/*" { | ||
capabilities = ["create", "read", "update", "delete", "list"] | ||
} | ||
path "pi-network/auth/*" { | ||
capabilities = ["create", "read", "update", "delete", "list"] | ||
} | ||
EOF | ||
} | ||
|
||
# Create a Vault role for the Pi Network | ||
resource "vault_role" "pi_network" { | ||
name = "pi-network-role" | ||
namespace = vault_namespace.pi_network.path | ||
policy_ids = [vault_policy.pi_network.id] | ||
token_ttl = 3600 | ||
token_max_ttl = 86400 | ||
} | ||
|
||
# Create a Vault secret engine for the Pi Network | ||
resource "vault_mount" "pi_network_secret" { | ||
path = "pi-network/secret" | ||
type = "kv" | ||
description = "Pi Network secret engine" | ||
} | ||
|
||
# Create a Vault secret for the Pi Network | ||
resource "vault_kv_secret" "pi_network_secret" { | ||
path = vault_mount.pi_network_secret.path | ||
data_json = <<EOF | ||
{ | ||
"username": "pi-network", | ||
"password": "your_secret_password" | ||
} | ||
EOF | ||
} | ||
|
||
# Create a Vault auth backend for the Pi Network | ||
resource "vault_auth_backend" "pi_network" { | ||
type = "ldap" | ||
path = "pi-network/auth" | ||
description = "Pi Network auth backend" | ||
|
||
config = { | ||
url = "ldap://ldap.pi-network.com" | ||
userdn = "cn=admin,dc=pi-network,dc=com" | ||
password = "your_ldap_password" | ||
} | ||
} | ||
|
||
# Create a Vault auth role for the Pi Network | ||
resource "vault_auth_role" "pi_network" { | ||
name = "pi-network-auth-role" | ||
auth_backend = vault_auth_backend.pi_network.path | ||
token_policies = [vault_policy.pi_network.id] | ||
} | ||
|
||
# Output the Vault role ID and token | ||
output "pi_network_role_id" { | ||
value = vault_role.pi_network.id | ||
} | ||
|
||
output "pi_network_token" { | ||
value = vault_role.pi_network.token | ||
sensitive = true | ||
} |