Skip to content

Instantly share code, notes, and snippets.

@trodemaster
Created September 27, 2021 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trodemaster/98e49be72a04436b70fbf6288fa0061d to your computer and use it in GitHub Desktop.
Save trodemaster/98e49be72a04436b70fbf6288fa0061d to your computer and use it in GitHub Desktop.
# setup the secrets engine
resource "vault_gcp_secret_backend" "gcp" {
description = var.GCP_SE_DESCRIPTION
path = "gcp/${var.GCP_SE_PATH}"
credentials = file(var.GCP_SE_CREDENTIALS_PATH) # google credentials in a json file
default_lease_ttl_seconds = var.GCP_SE_TTL
max_lease_ttl_seconds = var.GCP_SE_TTL_MAX
}
# Setup the role binding
resource "vault_gcp_secret_roleset" "gcp_se" {
backend = vault_gcp_secret_backend.gcp.path
roleset = var.GCP_SE_ROLESET
secret_type = "service_account_key"
project = var.GCP_SE_PROJECT
token_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
binding {
resource = "//cloudresourcemanager.googleapis.com/projects/${var.GCP_SE_PROJECT}"
roles = var.GCP_SE_ROLES
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment