From b67b121a28b1c7e0cd2f53f5834777199ced2bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20Niesiob=C4=99dzki?= Date: Mon, 20 Oct 2025 15:22:26 +0000 Subject: [PATCH] Context tests for Cloud Function v1 --- .../modules/cloud_function_v1/context.tfvars | 56 +++++++++++++++++ tests/modules/cloud_function_v1/context.yaml | 60 +++++++++++++++++++ tests/modules/cloud_function_v1/tftest.yaml | 1 + 3 files changed, 117 insertions(+) create mode 100644 tests/modules/cloud_function_v1/context.tfvars create mode 100644 tests/modules/cloud_function_v1/context.yaml diff --git a/tests/modules/cloud_function_v1/context.tfvars b/tests/modules/cloud_function_v1/context.tfvars new file mode 100644 index 000000000..558271b35 --- /dev/null +++ b/tests/modules/cloud_function_v1/context.tfvars @@ -0,0 +1,56 @@ +name = "test-cf-kms" +bucket_name = "bucket" +bundle_config = { + path = "gs://assets/sample-function.zip" +} +context = { + cidr_ranges = { + test = "10.10.20.0/28" + } + custom_roles = { + myrole_one = "organizations/366118655033/roles/myRoleOne" + } + iam_principals = { + mygroup = "group:test-group@example.com" + } + kms_keys = { + test = "projects/foo-prod-sec-core/locations/global/keyRings/prod-global-default/cryptoKeys/compute" + } + locations = { + ew8 = "europe-west8" + } + networks = { + test = "projects/foo-dev-net-spoke-0/global/networks/dev-spoke-0" + } + project_ids = { + test = "foo-test-0" + } + subnets = { + test = "projects/foo-dev-net-spoke-0/regions/europe-west1/subnetworks/gce" + } +} +kms_key = "$kms_keys:test" +iam = { + "$custom_roles:myrole_one" = [ + "$iam_principals:mygroup" + ] +} +project_id = "$project_ids:test" +region = "$locations:ew8" +service_account_config = { + roles = [ + "$custom_roles:myrole_one" + ] +} +vpc_connector = { + create = true + name = "connector_name" +} +vpc_connector_config = { + ip_cidr_range = "$cidr_ranges:test" + network = "$networks:test" + instances = { + max = 10 + min = 3 + } +} diff --git a/tests/modules/cloud_function_v1/context.yaml b/tests/modules/cloud_function_v1/context.yaml new file mode 100644 index 000000000..6417d4548 --- /dev/null +++ b/tests/modules/cloud_function_v1/context.yaml @@ -0,0 +1,60 @@ +# Copyright 2025 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. + +values: + google_cloudfunctions_function.function: + kms_key_name: projects/foo-prod-sec-core/locations/global/keyRings/prod-global-default/cryptoKeys/compute + project: foo-test-0 + region: europe-west8 + service_account_email: test-cf-kms@foo-test-0.iam.gserviceaccount.com + google_cloudfunctions_function_iam_binding.default["$custom_roles:myrole_one"]: + condition: [] + members: + - group:test-group@example.com + project: foo-test-0 + region: europe-west8 + role: organizations/366118655033/roles/myRoleOne + google_project_iam_member.default["organizations/366118655033/roles/myRoleOne"]: + condition: [] + member: serviceAccount:test-cf-kms@foo-test-0.iam.gserviceaccount.com + project: foo-test-0 + role: organizations/366118655033/roles/myRoleOne + google_service_account.service_account[0]: + account_id: test-cf-kms + create_ignore_already_exists: null + description: null + disabled: false + display_name: test-cf-kms + email: test-cf-kms@foo-test-0.iam.gserviceaccount.com + member: serviceAccount:test-cf-kms@foo-test-0.iam.gserviceaccount.com + project: foo-test-0 + timeouts: null + google_vpc_access_connector.connector[0]: + ip_cidr_range: 10.10.20.0/28 + machine_type: e2-micro + max_instances: 10 + min_instances: 3 + name: connector_name + network: projects/foo-dev-net-spoke-0/global/networks/dev-spoke-0 + project: foo-test-0 + region: europe-west8 + subnet: [] + timeouts: null + +counts: + google_cloudfunctions_function: 1 + google_cloudfunctions_function_iam_binding: 1 + google_project_iam_member: 1 + google_service_account: 1 + google_vpc_access_connector: 1 diff --git a/tests/modules/cloud_function_v1/tftest.yaml b/tests/modules/cloud_function_v1/tftest.yaml index 448e96615..ea15fe700 100644 --- a/tests/modules/cloud_function_v1/tftest.yaml +++ b/tests/modules/cloud_function_v1/tftest.yaml @@ -14,4 +14,5 @@ module: modules/cloud-function-v1 tests: + context: kms: