Skip to content

Commit 71ea320

Browse files
cloud-foundation-botmorgantebharathkkb
authored
chore: update tests to use 1.0 image and update compat note (#614)
* chore: update tests to use 1.0 image and update compat note * switch from v1.0 to v1 * fix: attempt workaround for #635 * fix: avoid using setproduct in shared vpc access * disable terraform version verification in tests Co-authored-by: Morgante Pell <morgantep@google.com> Co-authored-by: Bharath KKB <bharathkrishnakb@gmail.com>
1 parent 40ba6da commit 71ea320

File tree

18 files changed

+160
-20
lines changed

18 files changed

+160
-20
lines changed

.github/release-please.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
releaseType: terraform-module
216
handleGHRelease: true

.github/workflows/stale.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: "Close stale issues"
216
on:
317
schedule:

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ credentials.json
4848
env/
4949
test/fixtures/shared/terraform.tfvars
5050
.envrc
51+
52+
# tf lock file
53+
.terraform.lock.hcl

.kitchen.yml

+8
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,37 @@ suites:
3030
- name: minimal
3131
driver:
3232
name: terraform
33+
verify_version: false
3334
command_timeout: 1800
3435
root_module_directory: test/fixtures/minimal
3536
- name: vpc_sc_project
3637
driver:
3738
name: terraform
39+
verify_version: false
3840
command_timeout: 1800
3941
root_module_directory: test/fixtures/vpc_sc_project
4042
- name: fabric_project
4143
driver:
4244
name: terraform
45+
verify_version: false
4346
command_timeout: 1800
4447
root_module_directory: test/fixtures/fabric_project
4548
- name: app_engine
4649
driver:
4750
name: terraform
51+
verify_version: false
4852
command_timeout: 1800
4953
root_module_directory: test/fixtures/app_engine
5054
- name: budget
5155
driver:
5256
name: terraform
57+
verify_version: false
5358
command_timeout: 1800
5459
root_module_directory: test/fixtures/budget
5560
- name: dynamic_shared_vpc
5661
driver:
5762
name: terraform
63+
verify_version: false
5864
command_timeout: 1800
5965
root_module_directory: test/fixtures/dynamic_shared_vpc
6066
verifier:
@@ -75,11 +81,13 @@ suites:
7581
# - name: full
7682
# driver:
7783
# name: terraform
84+
# verify_version: false
7885
# command_timeout: 1800
7986
# root_module_directory: test/fixtures/full
8087
# - name: "shared_vpc_no_subnets"
8188
# driver:
8289
# name: "terraform"
90+
# verify_version: false
8391
# command_timeout: 1800
8492
# root_module_directory: test/fixtures/shared_vpc_no_subnets/
8593
# verifier:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Make will use bash instead of sh
1919
SHELL := /usr/bin/env bash
2020

21-
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
21+
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1
2222
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
2323
REGISTRY_URL := gcr.io/cloud-foundation-cicd
2424

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ To include G Suite integration for creating groups and adding Service Accounts i
1212

1313
## Compatibility
1414

15-
This module is meant for use with Terraform 0.13. If you haven't
15+
This module is meant for use with Terraform 0.13+ and tested using Terraform 1.0+. If you find incompatibilities using Terraform >=0.13, please open an issue.
16+
If you haven't
1617
[upgraded][terraform-0.13-upgrade] and need a Terraform
1718
0.12.x-compatible version of this module, the last released version
1819
intended for Terraform 0.12.x is [9.2.0].

build/int.cloudbuild.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ tags:
150150
- 'integration'
151151
substitutions:
152152
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
153-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
153+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1'
154154
options:
155155
machineType: 'N1_HIGHCPU_8'
156156
env:

build/lint.cloudbuild.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ tags:
2121
- 'lint'
2222
substitutions:
2323
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
24-
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
24+
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1'

examples/shared_vpc/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module "host-project" {
3838
*****************************************/
3939
module "vpc" {
4040
source = "terraform-google-modules/network/google"
41-
version = "~> 2.5.0"
41+
version = "~> 3.0"
4242

4343
project_id = module.host-project.project_id
4444
network_name = var.network_name

modules/shared_vpc_access/main.tf

+11-8
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ locals {
3030
}
3131
gke_shared_vpc_enabled = contains(var.active_apis, "container.googleapis.com")
3232
composer_shared_vpc_enabled = contains(var.active_apis, "composer.googleapis.com")
33-
active_apis = setintersection(keys(local.apis), var.active_apis)
34-
subnetwork_api = length(var.shared_vpc_subnets) != 0 ? tolist(setproduct(local.active_apis, var.shared_vpc_subnets)) : []
33+
active_apis = [for api in keys(local.apis) : api if contains(var.active_apis, api)]
34+
# Can't use setproduct due to https://github.com/terraform-google-modules/terraform-google-project-factory/issues/635
35+
subnetwork_api = length(var.shared_vpc_subnets) != 0 ? flatten([
36+
for i, api in local.active_apis : [for i, subnet in var.shared_vpc_subnets : "${api},${subnet}"]
37+
]) : []
3538
}
3639

3740
/******************************************
@@ -47,19 +50,19 @@ resource "google_compute_subnetwork_iam_member" "service_shared_vpc_subnet_users
4750
provider = google-beta
4851
count = var.grant_services_network_role ? length(local.subnetwork_api) : 0
4952
subnetwork = element(
50-
split("/", local.subnetwork_api[count.index][1]),
53+
split("/", split(",", local.subnetwork_api[count.index])[1]),
5154
index(
52-
split("/", local.subnetwork_api[count.index][1]),
55+
split("/", split(",", local.subnetwork_api[count.index])[1]),
5356
"subnetworks",
5457
) + 1,
5558
)
5659
role = "roles/compute.networkUser"
5760
region = element(
58-
split("/", local.subnetwork_api[count.index][1]),
59-
index(split("/", local.subnetwork_api[count.index][1]), "regions") + 1,
61+
split("/", split(",", local.subnetwork_api[count.index])[1]),
62+
index(split("/", split(",", local.subnetwork_api[count.index])[1]), "regions") + 1,
6063
)
6164
project = var.host_project_id
62-
member = format("serviceAccount:%s", local.apis[local.subnetwork_api[count.index][0]])
65+
member = format("serviceAccount:%s", local.apis[split(",", local.subnetwork_api[count.index])[0]])
6366
}
6467

6568
/******************************************
@@ -68,7 +71,7 @@ resource "google_compute_subnetwork_iam_member" "service_shared_vpc_subnet_users
6871
if "dataflow.googleapis.com" compute.networkUser role granted to dataflow service account for Dataflow on shared VPC Project if no subnets defined
6972
*****************************************/
7073
resource "google_project_iam_member" "service_shared_vpc_user" {
71-
for_each = (length(var.shared_vpc_subnets) == 0) && var.enable_shared_vpc_service_project && var.grant_services_network_role ? local.active_apis : []
74+
for_each = (length(var.shared_vpc_subnets) == 0) && var.enable_shared_vpc_service_project && var.grant_services_network_role ? toset(local.active_apis) : []
7275
project = var.host_project_id
7376
role = "roles/compute.networkUser"
7477
member = format("serviceAccount:%s", local.apis[each.value])

test/integration/app_engine/inspec.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: app_engine
216
attributes:
317
- name: project_id

test/integration/budget/inspec.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: budget
216
attributes:
317
- name: project_id

test/integration/dynamic_shared_vpc/inspec.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: dynamic_shared_vpc
216
depends:
317
- name: inspec-gcp

test/integration/fabric_project/inspec.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: fabric_project
216
attributes:
317
- name: project_id

test/integration/full/inspec.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: full
216
attributes:
317
- name: project_name

test/integration/minimal/inspec.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: minimal
216
attributes:
317
- name: project_id

test/integration/vpc_sc_project/inspec.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
name: vpc_sc_project
216
attributes:
317
- name: project_id

test/setup/main.tf

+6-7
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ resource "google_folder" "ci_pfactory_folder" {
2525

2626
module "pfactory_project" {
2727
source = "terraform-google-modules/project-factory/google"
28-
version = "~> 9.2"
28+
version = "~> 11.0"
2929

30-
name = "ci-pfactory-tests"
31-
random_project_id = true
32-
org_id = var.org_id
33-
folder_id = google_folder.ci_pfactory_folder.id
34-
billing_account = var.billing_account
35-
skip_gcloud_download = true
30+
name = "ci-pfactory-tests"
31+
random_project_id = true
32+
org_id = var.org_id
33+
folder_id = google_folder.ci_pfactory_folder.id
34+
billing_account = var.billing_account
3635

3736
activate_apis = [
3837
"admin.googleapis.com",

0 commit comments

Comments
 (0)