The module consolidates the management of crypto keys in an existing or new customer-managed key ring in GCP KMS. Keys are supplied as input parameters of the module to keep their management in a single code block. Supported key purpose types: CRYPTO_KEY_PURPOSE_UNSPECIFIED, ENCRYPT_DECRYPT, ASYMMETRIC_SIGN, ASYMMETRIC_DECRYPT, RAW_ENCRYPT_DECRYPT, MAC, KEY_ENCAPSULATION, and AES_WRAPPING.

NOTE: key rings and crypto keys cannot be deleted from Google Cloud Platform. Destroying a Terraform-managed resource will remove it from state but will not delete the resource from the project. Destroying a Terraform-managed crypto key will remove it from state and delete all crypto key versions. When Terraform destroys the keys, any data previously encrypted with these keys will be irrecoverable

Log in to Corewide IaC registry

Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:

 shellterraform login solutions.corewide.com
Provision instructions

Initialize mandatory providers:

Copy and paste into your Terraform configuration and insert the variables:

 hclmodule "tf_gcp_kms_key_ring" {
  source  = "solutions.corewide.com/google-cloud/tf-gcp-kms-key-ring/google"
  version = "~> 1.0.0"

  # specify module inputs here or try one of the examples below
  ...
}

Initialize the setup:

 shellterraform init
Define update strategy

Corewide DevOps team strictly follows Semantic Versioning Specification to provide our clients with products that have predictable upgrades between versions. We recommend pinning patch versions of our modules using pessimistic constraint operator (~>) to prevent breaking changes during upgrades.

To get new features during the upgrades (without breaking compatibility), use ~> 1.0 and run terraform init -upgrade

For the safest setup, use strict pinning with version = "1.0.0"

Key ring in GCP KMS

Customer-managed key ring in GCP KMS
Module
83% off
$300
$51
TOTAL $51
BUY
v1.0.0 released 1 week, 6 days ago

The module consolidates the management of crypto keys in an existing or new customer-managed key ring in GCP KMS. Keys are supplied as input parameters of the module to keep their management in a single code block. Supported key purpose types: CRYPTO_KEY_PURPOSE_UNSPECIFIED, ENCRYPT_DECRYPT, ASYMMETRIC_SIGN, ASYMMETRIC_DECRYPT, RAW_ENCRYPT_DECRYPT, MAC, KEY_ENCAPSULATION, and AES_WRAPPING.

NOTE: key rings and crypto keys cannot be deleted from Google Cloud Platform. Destroying a Terraform-managed resource will remove it from state but will not delete the resource from the project. Destroying a Terraform-managed crypto key will remove it from state and delete all crypto key versions. When Terraform destroys the keys, any data previously encrypted with these keys will be irrecoverable

Create a KMS key ring with a key:

 hclmodule "kms" {
  source  = "solutions.corewide.com/google-cloud/tf-gcp-kms-key-ring/google"
  version = "~> 1.0"

  key_ring_name = "foo"

  keys = [
    { name = "bar" },
  ]
}
Variable Description Type Default Required Sensitive
key_ring_name The name of the key ring string yes no
add_random_suffix Append a random suffix to the managed resource names to ensure uniqueness. Please note: modifying this variable will trigger the re-creation of the resources bool false no no
create_key_ring Toggle key ring creation bool true no no
keys List of keys parameters to create crypto keys list(object) [] no no
keys[*].name Name of the crypto key string yes no
keys[*].purpose Determines the cryptographic operations for which the crypto key can be used. Possible values are: CRYPTO_KEY_PURPOSE_UNSPECIFIED, ENCRYPT_DECRYPT, ASYMMETRIC_SIGN, ASYMMETRIC_DECRYPT, RAW_ENCRYPT_DECRYPT, MAC, KEY_ENCAPSULATION, and AES_WRAPPING string ENCRYPT_DECRYPT no no
keys[*].rotation_period Rotation period in days. Possible values are from 0 to 36500, where 0 means manual rotation number 0 no no
region GCP region to create resources in. Default GCP provider region used if not specified string no no
Output Description Type Sensitive
key_ring Key ring attributes computed no
keys Crypto keys resource attributes resource no
Dependency Version Kind
terraform >= 1.9 CLI
hashicorp/google ~> 8.4 provider
hashicorp/random ~> 3.6 provider

Not sure where to start?
Let's find your perfect match.