From 8d4b928d7dbe6ff59c92d8ca96c4ea61707dec72 Mon Sep 17 00:00:00 2001 From: Nikhil Bhoyar Date: Wed, 11 Dec 2024 16:06:17 +0530 Subject: [PATCH] Removing redundant variable kms_project_id from setup --- .terraform.lock | 0 examples/autokey_setup/variables.tf | 4 +-- examples/bucket_setup_using_autokey/main.tf | 2 +- .../bucket_setup_using_autokey/outputs.tf | 4 +-- .../bucket_setup_using_autokey/variables.tf | 8 ++--- modules/autokey/README.md | 3 +- test/fixtures/autokey_setup_fixture/main.tf | 5 +++ .../fixtures/autokey_setup_fixture/outputs.tf | 25 +++++++++++++ .../autokey_setup_fixture/variables.tf | 26 ++++++++++++++ .../main.tf | 7 ++++ .../outputs.tf | 25 +++++++++++++ .../variables.tf | 36 +++++++++++++++++++ test/setup/outputs.tf | 4 --- 13 files changed, 134 insertions(+), 15 deletions(-) delete mode 100644 .terraform.lock create mode 100644 test/fixtures/autokey_setup_fixture/main.tf create mode 100644 test/fixtures/autokey_setup_fixture/outputs.tf create mode 100644 test/fixtures/autokey_setup_fixture/variables.tf create mode 100644 test/fixtures/bucket_setup_using_autokey_fixture/main.tf create mode 100644 test/fixtures/bucket_setup_using_autokey_fixture/outputs.tf create mode 100644 test/fixtures/bucket_setup_using_autokey_fixture/variables.tf diff --git a/.terraform.lock b/.terraform.lock deleted file mode 100644 index e69de29..0000000 diff --git a/examples/autokey_setup/variables.tf b/examples/autokey_setup/variables.tf index 8639df6..9dabd4b 100644 --- a/examples/autokey_setup/variables.tf +++ b/examples/autokey_setup/variables.tf @@ -15,12 +15,12 @@ */ variable "kms_project_id" { - description = "The ID of the project in which kms keyring and kms keys will be provisioned by autokey." + description = "The ID of the project in which KMS keyring and KMS keys will be provisioned by autokey." type = string } variable "folder_id" { type = string - description = "The ID of the folder for which to configure and enable Autokey feature. Required when using Autokey." + description = "The ID of the folder for which to configure and enable Autokey feature." } diff --git a/examples/bucket_setup_using_autokey/main.tf b/examples/bucket_setup_using_autokey/main.tf index ce61d51..1ba6c08 100644 --- a/examples/bucket_setup_using_autokey/main.tf +++ b/examples/bucket_setup_using_autokey/main.tf @@ -48,7 +48,7 @@ resource "google_kms_key_handle" "bucket_keyhandle" { module "bucket" { source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket" - version = "8.0" + version = "~> 8.0.3" name = "${var.resource_project_id}-bucket-${random_string.suffix.result}" project_id = var.resource_project_id diff --git a/examples/bucket_setup_using_autokey/outputs.tf b/examples/bucket_setup_using_autokey/outputs.tf index 2a77391..9e5ed94 100644 --- a/examples/bucket_setup_using_autokey/outputs.tf +++ b/examples/bucket_setup_using_autokey/outputs.tf @@ -15,11 +15,11 @@ */ output "bucket_keyhandle" { - description = "An Autokey configuration identifier." + description = "Keyhandle configuration created for the bucket." value = resource.google_kms_key_handle.bucket_keyhandle } output "bucket_name" { - description = "A map of KeyHandles created." + description = "Name of the bucket created." value = module.bucket.name } diff --git a/examples/bucket_setup_using_autokey/variables.tf b/examples/bucket_setup_using_autokey/variables.tf index cc02c2a..8e973f4 100644 --- a/examples/bucket_setup_using_autokey/variables.tf +++ b/examples/bucket_setup_using_autokey/variables.tf @@ -15,22 +15,22 @@ */ variable "kms_project_id" { - description = "The ID of the project in which kms keyring and kms keys will be provisioned by autokey." + description = "The ID of the project in which KMS keyring and KMS keys will be provisioned by autokey." type = string } variable "folder_id" { type = string - description = "The ID of the folder for which to configure and enable Autokey feature. Required when using Autokey." + description = "The ID of the folder for which to configure and enable Autokey feature." } variable "resource_project_id" { - description = "The ID of the project in which to provision resources (bucket, persistent disk, etc)" + description = "The ID of the project in which to provision cloud storage bucket resource." type = string } variable "bucket_location" { type = string - description = "The gcp location where storage bucket will be created" + description = "The GCP location where storage bucket will be created" default = "us-central1" } diff --git a/modules/autokey/README.md b/modules/autokey/README.md index bd18d0a..ef6d37d 100644 --- a/modules/autokey/README.md +++ b/modules/autokey/README.md @@ -1,7 +1,6 @@ # Autokey submodule -This is a submodule built to make [KMS Autokey](https://cloud.google.com/kms/docs/autokey-overview) feature simple to be used. This submodule will create the [Autokey Config](https://cloud.google.com/kms/docs/enable-autokey#enable-autokey-folder) for an existing folder where you want to enable Autokey, set up the Cloud KMS [service agent](https://cloud.google.com/kms/docs/enable-autokey#autokey-service-agent) on an existing key project and create [Key Handles](https://cloud.google.com/kms/docs/resource-hierarchy#key_handles) for existing resource projects. - +This is a submodule built to make [KMS Autokey](https://cloud.google.com/kms/docs/autokey-overview) feature simple to be used. This submodule will create the [Autokey Config](https://cloud.google.com/kms/docs/enable-autokey#enable-autokey-folder) for an existing folder where you want to enable Autokey, set up the Cloud KMS [service agent](https://cloud.google.com/kms/docs/enable-autokey#autokey-service-agent) on an existing key project. ## Inputs diff --git a/test/fixtures/autokey_setup_fixture/main.tf b/test/fixtures/autokey_setup_fixture/main.tf new file mode 100644 index 0000000..85dbf31 --- /dev/null +++ b/test/fixtures/autokey_setup_fixture/main.tf @@ -0,0 +1,5 @@ +module "autokey_setup_fixture" { + source = "../../../examples/autokey_setup" + kms_project_id = var.project_id + folder_id = var.folder_id +} diff --git a/test/fixtures/autokey_setup_fixture/outputs.tf b/test/fixtures/autokey_setup_fixture/outputs.tf new file mode 100644 index 0000000..e2818f9 --- /dev/null +++ b/test/fixtures/autokey_setup_fixture/outputs.tf @@ -0,0 +1,25 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + +output "autokey_config_id" { + description = "An Autokey configuration identifier." + value = module.autokey_setup_fixture.autokey_config_id +} + +output "kms_project_id" { + description = "The ID of the project in which KMS keyring and KMS keys will be provisioned by autokey." + value = var.project_id +} diff --git a/test/fixtures/autokey_setup_fixture/variables.tf b/test/fixtures/autokey_setup_fixture/variables.tf new file mode 100644 index 0000000..d992660 --- /dev/null +++ b/test/fixtures/autokey_setup_fixture/variables.tf @@ -0,0 +1,26 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + +variable "project_id" { + description = "The ID of the project in which KMS keyring and KMS keys will be provisioned by autokey." + type = string +} + +variable "folder_id" { + description = "The ID of the folder for which to configure and enable Autokey feature." + type = string + +} diff --git a/test/fixtures/bucket_setup_using_autokey_fixture/main.tf b/test/fixtures/bucket_setup_using_autokey_fixture/main.tf new file mode 100644 index 0000000..7938f22 --- /dev/null +++ b/test/fixtures/bucket_setup_using_autokey_fixture/main.tf @@ -0,0 +1,7 @@ +module "bucket_setup_using_autokey_fixture" { + source = "../../../examples/bucket_setup_using_autokey" + kms_project_id = var.project_id + folder_id = var.folder_id + resource_project_id = var.resource_project_id + bucket_location = var.bucket_location +} diff --git a/test/fixtures/bucket_setup_using_autokey_fixture/outputs.tf b/test/fixtures/bucket_setup_using_autokey_fixture/outputs.tf new file mode 100644 index 0000000..bc53167 --- /dev/null +++ b/test/fixtures/bucket_setup_using_autokey_fixture/outputs.tf @@ -0,0 +1,25 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + +output "bucket_keyhandle" { + description = "Keyhandle configuration created for the bucket." + value = module.bucket_setup_using_autokey_fixture.bucket_keyhandle +} + +output "bucket_name" { + description = "Name of the bucket created." + value = module.bucket_setup_using_autokey_fixture.bucket_name +} diff --git a/test/fixtures/bucket_setup_using_autokey_fixture/variables.tf b/test/fixtures/bucket_setup_using_autokey_fixture/variables.tf new file mode 100644 index 0000000..68cddfa --- /dev/null +++ b/test/fixtures/bucket_setup_using_autokey_fixture/variables.tf @@ -0,0 +1,36 @@ +/** + * Copyright 2024 Google LLC + * + * 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. + */ + +variable "project_id" { + description = "The ID of the project in which KMS keyring and KMS keys will be provisioned by autokey." + type = string +} + +variable "folder_id" { + type = string + description = "The ID of the folder for which to configure and enable Autokey feature." +} + +variable "resource_project_id" { + description = "The ID of the project in which to provision cloud storage bucket resources." + type = string +} + +variable "bucket_location" { + type = string + description = "The GCP location where storage bucket will be created" + default = "us-central1" +} diff --git a/test/setup/outputs.tf b/test/setup/outputs.tf index 5bf5c7a..2d9a328 100644 --- a/test/setup/outputs.tf +++ b/test/setup/outputs.tf @@ -14,10 +14,6 @@ * limitations under the License. */ -output "kms_project_id" { - value = module.project_ci_kms.project_id -} - output "project_id" { value = module.project_ci_kms.project_id }