All Projects → mbrancato → Terraform Google Vault

mbrancato / Terraform Google Vault

Licence: apache-2.0
Terraform module to deploy Vault as a container on Google Cloud Run

Projects that are alternatives of or similar to Terraform Google Vault

Terraformer
CLI tool to generate terraform files from existing infrastructure (reverse Terraform). Infrastructure to Code
Stars: ✭ 6,316 (+25164%)
Mutual labels:  google-cloud, terraform, hcl
Airflow Toolkit
Any Airflow project day 1, you can spin up a local desktop Kubernetes Airflow environment AND one in Google Cloud Composer with tested data pipelines(DAGs) 🖥 >> [ 🚀, 🚢 ]
Stars: ✭ 51 (+104%)
Mutual labels:  google-cloud, terraform, hcl
Terraform Gcp Kubernetes Traefik
Little example of how to deploy a gke cluster with terraform and use traefik as ingress controller
Stars: ✭ 39 (+56%)
Mutual labels:  google-cloud-platform, terraform, hcl
Typhoon
Minimal and free Kubernetes distribution with Terraform
Stars: ✭ 1,397 (+5488%)
Mutual labels:  google-cloud, terraform, hcl
Atlantis On Gke
A set of @HashiCorp Terraform configurations for running Atlantis on @GoogleCloud GKE
Stars: ✭ 44 (+76%)
Mutual labels:  google-cloud, terraform, hcl
Terraform Kubernetes
Example of deploying a Kubernetes cluster to Google Cloud using Terraform
Stars: ✭ 152 (+508%)
Mutual labels:  google-cloud, terraform, hcl
K2tf
Kubernetes YAML to Terraform HCL converter
Stars: ✭ 477 (+1808%)
Mutual labels:  terraform, hcl
Infrastructure As Code Talk
Sample code for the talk "Infrastructure-as-code: running microservices on AWS with Docker, ECS, and Terraform"
Stars: ✭ 520 (+1980%)
Mutual labels:  terraform, hcl
Terraform Openstack Rke
Terraform Openstack RKE
Stars: ✭ 23 (-8%)
Mutual labels:  terraform, hcl
Tectonic Installer
Install a Kubernetes cluster the CoreOS Tectonic Way: HA, self-hosted, RBAC, etcd Operator, and more
Stars: ✭ 599 (+2296%)
Mutual labels:  terraform, hcl
Vault On Gke
Run @HashiCorp Vault on Google Kubernetes Engine (GKE) with Terraform
Stars: ✭ 453 (+1712%)
Mutual labels:  terraform, hcl
Intro To Terraform
Sample code for the blog post series "A Comprehensive Guide to Terraform."
Stars: ✭ 550 (+2100%)
Mutual labels:  terraform, hcl
Terraform Ecs
AWS ECS terraform module
Stars: ✭ 657 (+2528%)
Mutual labels:  terraform, hcl
Terragoat
TerraGoat is Bridgecrew's "Vulnerable by Design" Terraform repository. TerraGoat is a learning and training project that demonstrates how common configuration errors can find their way into production cloud environments.
Stars: ✭ 461 (+1744%)
Mutual labels:  terraform, hcl
Bedrock
Automation for Production Kubernetes Clusters with a GitOps Workflow
Stars: ✭ 528 (+2012%)
Mutual labels:  terraform, hcl
Terracognita
Reads from existing Cloud Providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
Stars: ✭ 452 (+1708%)
Mutual labels:  google-cloud-platform, terraform
Terraform Aws Secure Baseline
Terraform module to set up your AWS account with the secure baseline configuration based on CIS Amazon Web Services Foundations and AWS Foundational Security Best Practices.
Stars: ✭ 596 (+2284%)
Mutual labels:  terraform, hcl
Vscode Terraform
A Visual Studio Code extension for Hashicorp Terraform
Stars: ✭ 672 (+2588%)
Mutual labels:  terraform, hcl
Vim Terraform
basic vim/terraform integration
Stars: ✭ 668 (+2572%)
Mutual labels:  terraform, hcl
Fdb Cloud Test
Packer + Terraform setup to experiment with FDB clusters in the cloud.
Stars: ✭ 23 (-8%)
Mutual labels:  terraform, hcl

Vault Google Cloud Run Module

This is a Terraform module to deploy a Vault instance on Google's Cloud Run service. Vault is an open-source secrets management tool that generally is run in a high-availability (HA) cluster. This implementation is a single instance with auto-unseal and no HA support. Cloud Run is a way to easily run a container on Google Cloud without an orchestrator. This module makes use of the following Google Cloud resources:

  • Google Cloud Run
  • Google Cloud Storage
  • Google Cloud Key Management Service

Table of Contents

Getting Started

To get started, a Google Cloud Project is needed. This should be created ahead of time or using Terraform, but is outside the scope of this module. This project ID is provided to the module invocation and a basic implementation would look like the following:

provider "google" {}

data "google_client_config" "current" {}

module "vault" {
  providers = {
    google = google
  }

  source      = "git::https://github.com/mbrancato/terraform-google-vault.git"
  name        = "vault"
  project     = data.google_client_config.current.project
  location    = data.google_client_config.current.region
  vault_image = "us.gcr.io/${data.google_client_config.current.project}/vault:1.6.1"
}

After creating the resources, the Vault instance may be initialized.

Set the VAULT_ADDR environment variable. See Vault URL.

$ export VAULT_ADDR=https://vault-jsn3uj5s1c-sg.a.run.app

Ensure the vault is operational (might take a minute or two), uninitialized and sealed.

$ vault status
Key                      Value
---                      -----
Recovery Seal Type       gcpckms
Initialized              false
Sealed                   true
Total Recovery Shares    0
Threshold                0
Unseal Progress          0/0
Unseal Nonce             n/a
Version                  n/a
HA Enabled               false

Initialize the vault.

$ vault operator init
Recovery Key 1: ...
Recovery Key 2: ...
Recovery Key 3: ...
Recovery Key 4: ...
Recovery Key 5: ...

Initial Root Token: s....

Success! Vault is initialized

Recovery key initialized with 5 key shares and a key threshold of 3. Please
securely distribute the key shares printed above.

From here, Vault is operational. Configure the auth methods needed and other settings. The Cloud Run Service may scale the container to zero, but the server configuration and unseal keys are configured. When restarting, the Vault should unseal itself automatically using the Google KMS. For more information on deploying Vault, read Deploy Vault.

Variables

name

  • Application name.

location

  • Google location where resources are to be created.

project

  • Google project ID.

vault_image

  • Vault docker image.

bucket_force_destroy (optional)

  • CAUTION: Set force_destroy for Storage Bucket. This is where the vault data is stored. Setting this to true will allow terraform destroy to delete the bucket.
    • default - false

container_concurrency (optional)

  • Max number of connections per container instance.
    • default - 80

vpc_connector (optional)

vault_ui (optional)

  • Enable Vault UI.
    • default - false

vault_api_addr (optional)

  • Full HTTP endpoint of Vault Server if using a custom domain name. Leave blank otherwise.
    • default - ""

vault_kms_keyring_name (optional)

  • Name of the Google KMS keyring to use.
    • default - "${var.name}-${lower(random_id.vault.hex)}-kr"

vault_kms_key_rotation (optional)

  • The period for KMS key rotation.
    • Note: key rotations will lead to multiple active KMS keys and will result in an increasing monthly bill. Setting to null should disable rotation (not recommended).
    • default - "7776000s" (90 days)

vault_kms_key_algorithm (optional)

  • The cryptographic algorithm to be used with the KMS key.

vault_kms_key_protection_level (optional)

  • The protection level to be used with the KMS key.
    • Specify the protection level to be used (SOFTWARE, HSM, EXTERNAL).
    • default - "SOFTWARE"

vault_service_account_id (optional)

  • ID for the service account to be used. This is the part of the service account email before the @ symbol.
    • default - "vault-sa"

vault_storage_bucket_name (optional)

  • Storage bucket name to be used.
    • default - "${var.name}-${lower(random_id.vault.hex)}-bucket"

Security Concerns

The following things may be of concern from a security perspective:

  • When not using a VPC connector, this is a publicly accessible Vault instance. Anyone with the DNS name can connect to it.
  • By default, Vault is running on shared compute infrastructure. The Google Terraform provider does not yet support Cloud Run on Anthos / GKE to deploy on single-tenant VMs.

Caveats

PLEASE READ

Google Cloud Container Registry

Cloud Run will only run containers hosted on gcr.io (GCR) and its subdomains. This means that the Vault container will need to be pushed to GCR in the Google Cloud Project. Terraform cannot currently create the container registry and it is automatically created using docker push. Read the documentation for more details on pushing containers to GCR.

A quick way to get Vault into GCR for a GCP project:

gcloud auth configure-docker
docker pull hashicorp/vault:latest
docker tag hashicorp/vault:1.6.1 gcr.io/{{ project_id }}/vault:1.6.1
docker push gcr.io/{{ project_id }}/vault:1.6.1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].