Skip to content

Terraform code to create a KMS key and its respective Keyring

Notifications You must be signed in to change notification settings

GeKasap/terraform-google-kms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Terraform - Create a KMS crypto key

This project is an implementation of Terraform KMS Crypto Key Layout. It creates a KMS Crypto Key and the respective Keyring. Support also a list of service accounts to grant them permissions.

Example

terraform {
  backend "gcs" {
    bucket  = "my-foo-bucket-tfstate"
    prefix  = "kms"
  }

  required_version = ">= 0.12"
}

provider "google-beta" {
  project = "my-foo-project"
  region  = "europe-west3"
  zone = "europe-west3-c"
}

module "my_cool_kms_key" {
  source = "./modules/terraform-google-kms"
  name = "my-cool-kms-key"
  location = "europe-west3"
  project = "my-foo-project"
  service_account = ["[email protected]"]
}

Variables

Variable name Type Description Default value
project string The ID of the project the resource belongs
location string Location of the cluster
name string The ID of the key and keyring
service_account list(string) A list of service accounts to grant permissions to that key

Building

Initialization

$ terraform init

Planning

Terraform allows you to "Plan", which allows you to see what it would change without actually making any changes.

$ terraform plan 

Applying

$ terraform apply

Modifying

If you want to update service accounts, then edit the terraform.tfvars file and run again terraform apply

$ terraform apply

Destroying

$ terraform destroy

Author

Georgios Kasapoglou

https://github.com/GeKasap

License

Copyright 2019 Georgios Kasapoglou

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Terraform code to create a KMS key and its respective Keyring

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages