From d2c373047eaabcbe8caad6838bab32f69b187ece Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 2 Jan 2025 08:57:28 -0800 Subject: [PATCH] adding datasource for autokeyconfig (#12611) (#20807) [upstream:9ca4299ff15c8f81506bbed2696bd30919c440db] Signed-off-by: Modular Magician --- .changelog/12611.txt | 3 ++ .../data_source_google_kms_auotokey_config.go | 3 ++ ..._source_google_kms_auotokey_config_test.go | 3 ++ google/services/kms/kms_utils.go | 8 ++++ .../docs/d/kms_autokey_config.html.markdown | 42 +++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 .changelog/12611.txt create mode 100644 google/services/kms/data_source_google_kms_auotokey_config.go create mode 100644 google/services/kms/data_source_google_kms_auotokey_config_test.go create mode 100644 website/docs/d/kms_autokey_config.html.markdown diff --git a/.changelog/12611.txt b/.changelog/12611.txt new file mode 100644 index 00000000000..a3a2ad694d3 --- /dev/null +++ b/.changelog/12611.txt @@ -0,0 +1,3 @@ +```release-note:new-datasource +`google_kms_autokey_config` +``` \ No newline at end of file diff --git a/google/services/kms/data_source_google_kms_auotokey_config.go b/google/services/kms/data_source_google_kms_auotokey_config.go new file mode 100644 index 00000000000..3d831111e11 --- /dev/null +++ b/google/services/kms/data_source_google_kms_auotokey_config.go @@ -0,0 +1,3 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 +package kms diff --git a/google/services/kms/data_source_google_kms_auotokey_config_test.go b/google/services/kms/data_source_google_kms_auotokey_config_test.go new file mode 100644 index 00000000000..1101bcd8559 --- /dev/null +++ b/google/services/kms/data_source_google_kms_auotokey_config_test.go @@ -0,0 +1,3 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 +package kms_test diff --git a/google/services/kms/kms_utils.go b/google/services/kms/kms_utils.go index e6ccb63195a..cbe9cc431db 100644 --- a/google/services/kms/kms_utils.go +++ b/google/services/kms/kms_utils.go @@ -28,6 +28,14 @@ type KmsKeyHandleId struct { Name string } +type KmsAutokeyConfigId struct { + Folder string +} + +func (s *KmsAutokeyConfigId) AutokeyConfigId() string { + return fmt.Sprintf("%s/autokeyConfig", s.Folder) +} + func (s *KmsKeyHandleId) KeyHandleId() string { return fmt.Sprintf("projects/%s/locations/%s/keyHandles/%s", s.Project, s.Location, s.Name) } diff --git a/website/docs/d/kms_autokey_config.html.markdown b/website/docs/d/kms_autokey_config.html.markdown new file mode 100644 index 00000000000..2654ec3016d --- /dev/null +++ b/website/docs/d/kms_autokey_config.html.markdown @@ -0,0 +1,42 @@ +--- +subcategory: "Cloud Key Management Service" +description: |- + Provides access to KMS Autokey config data with Google Cloud KMS. +--- + +# google_kms_key_handle + +Provides access to Google Cloud Platform KMS AutokeyConfig. A AutokeyConfig is a Cloud KMS resource that helps you safely span the separation of duties to create new Cloud KMS keys for CMEK using Autokey. + +~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider. +See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources. + + +For more information see +[the official documentation](https://cloud.google.com/kms/docs/reference/rest/v1/folders) +and +[API](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyHandles). + +## Example Usage + +```hcl +data "google_kms_autokey_config" "my_autokey_config" { + folder = "folders/123" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `folder` - The folder in which the AutokeyConfig is configured. If it + is not provided, the provider folder is used. + +## Attributes Reference + +In addition to the arguments listed above, the following computed attributes are +exported: + +* `id` - The identifier of the AutokeyConfig. Its format is `folders/{folderId}/autokeyConfig`. + +* `key_project` - The identifier of the project hosting KMS KeyRings and Keys generated by Autokey. Its format is `projects/{projectId}`. \ No newline at end of file