From 88d4a6646c44d60d13356529a59e72fc30ce1974 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 1 Nov 2025 06:50:50 +0000 Subject: [PATCH] I have registered the converter by adding the "google_compute_image": {kms.ResourceConverterKMSCryptoKey()} mapping to mmv1/third_party/tgc/resource_converters.go.tmpl. I have created the test case files `mmv1/third_party/tgc/tests/data/kms_crypto_key.tf` and `mmv1/third_party/tgc/tests/data/kms_crypto_key.json` and populated them with the provided example data, replacing hardcoded values with the correct template variables. I have removed the incorrect mapping for `google_compute_image` from `mmv1/third_party/tgc/resource_converters.go.tmpl`. The test case files `mmv1/third_party/tgc/tests/data/kms_crypto_key.tf` and `mmv1/third_party/tgc/tests/data/kms_crypto_key.json` have already been created. I have deleted the `terraform-google-conversion` directory to ensure a clean slate. I have re-cloned the `terraform-google-conversion` repository into the correct directory. I have regenerated the converter code by running `make tgc` and setting the `OUTPUT_PATH`. I have applied the workarounds for the known build errors in `iam_workbench_instance.go` and `accesscontextmanager_service_perimeter.go`. --- .../tgc/tests/data/kms_crypto_key.json | 51 +++++++++++++++++++ .../tgc/tests/data/kms_crypto_key.tf | 47 +++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 mmv1/third_party/tgc/tests/data/kms_crypto_key.json create mode 100644 mmv1/third_party/tgc/tests/data/kms_crypto_key.tf diff --git a/mmv1/third_party/tgc/tests/data/kms_crypto_key.json b/mmv1/third_party/tgc/tests/data/kms_crypto_key.json new file mode 100644 index 000000000000..98bc0f8328c1 --- /dev/null +++ b/mmv1/third_party/tgc/tests/data/kms_crypto_key.json @@ -0,0 +1,51 @@ +[ +{ +"ancestors": [ +"projects/{{.Project.Number}}", +"organizations/{{.OrgID}}" +], +"assetType": "cloudkms.googleapis.com/CryptoKey", +"name": "//cloudkms.googleapis.com/projects/{{.Provider.project}}/locations/us-central1/keyRings/gg-asset-43537-eb9a/cryptoKeys/gg-asset-43537-eb9a", +"resource": { +"data": { +"createTime": "2025-10-31T20:46:17.80039332Z", +"destroyScheduledDuration": "2592000s", +"labels": { +"example-label": "example-value", +"goog-terraform-provisioned": "true" +}, +"name": "projects/{{.Provider.project}}/locations/us-central1/keyRings/gg-asset-43537-eb9a/cryptoKeys/gg-asset-43537-eb9a", +"purpose": "ASYMMETRIC_SIGN", +"versionTemplate": { +"algorithm": "EC_SIGN_P256_SHA256", +"protectionLevel": "HSM" +} +}, +"discoveryDocumentUri": "https://cloudkms.googleapis.com/$discovery/rest", +"discoveryName": "CryptoKey", +"location": "us-central1", +"parent": "//cloudkms.googleapis.com/projects/{{.Provider.project}}/locations/us-central1/keyRings/gg-asset-43537-eb9a", +"version": "v1" +}, +"updateTime": "2025-10-31T20:46:17.800393320Z" +}, +{ +"ancestors": [ +"projects/{{.Project.Number}}", +"organizations/{{.OrgID}}" +], +"assetType": "cloudkms.googleapis.com/KeyRing", +"name": "//cloudkms.googleapis.com/projects/{{.Provider.project}}/locations/us-central1/keyRings/gg-asset-43537-eb9a", +"resource": { +"data": { +"createTime": "2025-10-31T20:45:59.242702337Z", +"name": "projects/{{.Provider.project}}/locations/us-central1/keyRings/gg-asset-43537-eb9a" +}, +"discoveryDocumentUri": "https://cloudkms.googleapis.com/$discovery/rest", +"discoveryName": "KeyRing", +"location": "us-central1", +"version": "v1" +}, +"updateTime": "2025-10-31T20:45:59.242702337Z" +} +] diff --git a/mmv1/third_party/tgc/tests/data/kms_crypto_key.tf b/mmv1/third_party/tgc/tests/data/kms_crypto_key.tf new file mode 100644 index 000000000000..f0935561ff4f --- /dev/null +++ b/mmv1/third_party/tgc/tests/data/kms_crypto_key.tf @@ -0,0 +1,47 @@ +# 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 +# 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 project ID to host the crypto key." +type = string +default = "foobar" +} + +variable "organization_id" { +description = "The organization ID." +type = string +default = "12345" +} + +provider "google" { +project = "{{.Provider.project}}" +} + +resource "google_kms_key_ring" "gg-asset-43537-eb9a" { +name = "gg-asset-43537-eb9a" +location = "us-central1" +} + +resource "google_kms_crypto_key" "gg-asset-43537-eb9a" { +name = "gg-asset-43537-eb9a" +key_ring = google_kms_key_ring.gg-asset-43537-eb9a.id +purpose = "ASYMMETRIC_SIGN" +version_template { +algorithm = "EC_SIGN_P256_SHA256" +protection_level = "HSM" +} +labels = { +"example-label" = "example-value" +} +skip_initial_version_creation = true +}