-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault.tf
18 lines (15 loc) · 791 Bytes
/
vault.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
resource "vault_database_secret_backend_connection" "postgres" {
backend = "${var.pipeline_name}/database"
name = "postgres"
allowed_roles = ["application"]
postgresql {
connection_url = "postgres://${var.db_username}:${var.db_password}@${aws_db_instance.example.endpoint}/${aws_db_instance.example.name}"
}
depends_on = [aws_db_instance.example]
}
resource "vault_database_secret_backend_role" "role" {
backend = "${var.pipeline_name}/database"
name = "application"
db_name = vault_database_secret_backend_connection.postgres.name
creation_statements = ["CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT SELECT ON ALL TABLES IN SCHEMA public TO \"{{name}}\";"]
}