Skip to content

Instantly share code, notes, and snippets.

@mr-pascal
Created January 1, 2022 10:30
Show Gist options
  • Select an option

  • Save mr-pascal/dd01f728a0a7b700feee3526391435a5 to your computer and use it in GitHub Desktop.

Select an option

Save mr-pascal/dd01f728a0a7b700feee3526391435a5 to your computer and use it in GitHub Desktop.
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "4.5.0"
}
}
}
provider "google" {}
resource "google_project_service" "kms_api" {
## Enabling GCP KMS API
project = var.project
service = "cloudkms.googleapis.com"
disable_on_destroy = false
}
resource "google_kms_key_ring" "my_key_ring" {
# Create the key ring on GCP
project = var.project
name = "sops-demo"
location = "global"
depends_on = [
google_project_service.kms_api]
}
resource "google_kms_crypto_key" "my_crypto_key" {
# Add a new create to the key ring
name = "my-encryption-key"
key_ring = google_kms_key_ring.my_key_ring.id
}
variable "project" {
description = "The GCP project"
type = string
default = "<YOUR_GCP_PROJECT>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment