Skip to content

Commit

Permalink
chore: update tests to use 1.0 image, enable module-swapper for tests (
Browse files Browse the repository at this point in the history
…#313)

* fix setup

* fix headers

* serial init, activate module swapper

* update readme

* switch image in makefile, targets for swapper

* update build images

* fmt

* add serviceUsageAdmin to allow disable api in example

* explicit dep for vpcaccess api c.g.c

* Update README.md

Co-authored-by: Morgante Pell <[email protected]>

Co-authored-by: Morgante Pell <[email protected]>
  • Loading branch information
bharathkkb and morgante authored Aug 13, 2021
1 parent be66cf4 commit 56b03fe
Show file tree
Hide file tree
Showing 19 changed files with 210 additions and 59 deletions.
14 changes: 14 additions & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# Copyright 2021 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.

releaseType: terraform-module
handleGHRelease: true
14 changes: 14 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: "Close stale issues"
on:
schedule:
Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 0.13
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.0
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down Expand Up @@ -69,6 +69,22 @@ docker_test_lint:
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/usr/local/bin/test_lint.sh

# Swap upstream registry refs to local refs
.PHONY: docker_swap_examples
docker_swap_examples:
docker run --rm -it \
-v $(CURDIR):/workspace \
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
module-swapper

# Restore local refs to upstream registry refs
.PHONY: docker_restore_examples
docker_restore_examples:
docker run --rm -it \
-v $(CURDIR):/workspace \
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
module-swapper -restore && terraform fmt -recursive

# Generate documentation
.PHONY: docker_generate_docs
docker_generate_docs:
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ Sub modules are provided for creating individual vpc, subnets, and routes. See t

## Compatibility

This module is meant for use with Terraform 0.12. If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-12.html) and need a Terraform 0.11.x-compatible version of this module, the last released version intended for Terraform 0.11.x is [0.8.0](https://registry.terraform.io/modules/terraform-google-modules/network/google/0.8.0).
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.

If you haven't [upgraded][terraform-0.13-upgrade] and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is [2.6.0].

## Usage
You can go to the examples folder, however the usage of the module could be like this in your own main.tf file:
Expand Down Expand Up @@ -185,3 +190,6 @@ In order to operate with the Service Account you must activate the following API

Refer to the [contribution guidelines](./CONTRIBUTING.md) for
information on contributing to this module.

[terraform-0.13-upgrade]: https://www.terraform.io/upgrade-guides/0-13.html
[2.6.0]: https://registry.terraform.io/modules/terraform-google-modules/network/google/2.6.0
62 changes: 16 additions & 46 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@

timeout: 3600s
steps:
- id: swap-module-refs
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && module-swapper']
- id: prepare
waitFor:
- swap-module-refs
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment']
env:
- 'TF_VAR_org_id=$_ORG_ID'
- 'TF_VAR_folder_id=$_FOLDER_ID'
- 'TF_VAR_billing_account=$_BILLING_ACCOUNT'
- id: create simple-project-local
- id: create all
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-project-local']
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create']
- id: converge simple-project-local
waitFor:
- create simple-project-local
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-project-local']
- id: verify simple-project-local
Expand All @@ -41,14 +46,9 @@ steps:
- verify simple-project-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-project-local']
- id: create simple-project-with-regional-network-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create simple-project-with-regional-network-local']
- id: converge simple-project-with-regional-network-local
waitFor:
- create simple-project-with-regional-network-local
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-project-with-regional-network-local']
- id: verify simple-project-with-regional-network-local
Expand All @@ -61,14 +61,9 @@ steps:
- verify simple-project-with-regional-network-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-project-with-regional-network-local']
- id: create secondary-ranges-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create secondary-ranges-local']
- id: converge secondary-ranges-local
waitFor:
- create secondary-ranges-local
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge secondary-ranges-local']
- id: verify secondary-ranges-local
Expand All @@ -81,14 +76,9 @@ steps:
- verify secondary-ranges-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy secondary-ranges-local']
- id: create multi-vpc-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create multi-vpc-local']
- id: converge multi-vpc-local
waitFor:
- create multi-vpc-local
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge multi-vpc-local']
- id: verify multi-vpc-local
Expand All @@ -101,14 +91,9 @@ steps:
- verify multi-vpc-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy multi-vpc-local']
- id: create delete-default-gateway-routes-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create delete-default-gateway-routes-local']
- id: converge delete-default-gateway-routes-local
waitFor:
- create delete-default-gateway-routes-local
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge delete-default-gateway-routes-local']
- id: verify delete-default-gateway-routes-local
Expand All @@ -121,14 +106,9 @@ steps:
- verify delete-default-gateway-routes-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy delete-default-gateway-routes-local']
- id: create submodule-firewall-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create submodule-firewall-local']
- id: converge submodule-firewall-local
waitFor:
- create submodule-firewall-local
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge submodule-firewall-local']
- id: verify submodule-firewall-local
Expand All @@ -141,14 +121,9 @@ steps:
- verify submodule-firewall-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy submodule-firewall-local']
- id: create submodule-network-peering-local
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create submodule-network-peering-local']
- id: converge submodule-network-peering-local
waitFor:
- create submodule-network-peering-local
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge submodule-network-peering-local']
- id: verify submodule-network-peering-local
Expand All @@ -161,14 +136,9 @@ steps:
- verify submodule-network-peering-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy submodule-network-peering-local']
- id: create submodule-vpc-serverless-connector-beta
waitFor:
- prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create submodule-vpc-serverless-connector-beta']
- id: converge submodule-vpc-serverless-connector-beta
waitFor:
- create submodule-vpc-serverless-connector-beta
- create all
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge submodule-vpc-serverless-connector-beta']
- id: verify submodule-vpc-serverless-connector-beta
Expand All @@ -186,4 +156,4 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
2 changes: 1 addition & 1 deletion build/lint.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tags:
- 'lint'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '0.13'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
2 changes: 1 addition & 1 deletion codelabs/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "google_project_service" "compute" {
# Create the network
module "vpc" {
source = "terraform-google-modules/network/google"
version = "~> 2.5.0"
version = "~> 3.0"

# Give the network a name and project
project_id = google_project_service.compute.project
Expand Down
5 changes: 4 additions & 1 deletion examples/submodule_vpc_serverless_connector/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ terraform {
}

# [START vpc_serverless_connector_enable_api]
resource "google_project_service" "project" {
resource "google_project_service" "vpcaccess-api" {
project = var.project_id # Replace this with your project ID in quotes
service = "vpcaccess.googleapis.com"
}
Expand Down Expand Up @@ -75,5 +75,8 @@ module "serverless-connector" {
# min_instances = 2
# max_instances = 7 }
]
depends_on = [
google_project_service.vpcaccess-api
]
}
# [END vpc_serverless_connector]
14 changes: 14 additions & 0 deletions test/integration/delete_default_gateway_routes/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: delete_default_gateway_routes
attributes:
- name: project_id
Expand Down
14 changes: 14 additions & 0 deletions test/integration/ilb_routing/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: ilb_routing
depends:
- name: inspec-gcp
Expand Down
14 changes: 14 additions & 0 deletions test/integration/multi_vpc/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: multi_vpc
attributes:
- name: project_id
Expand Down
14 changes: 14 additions & 0 deletions test/integration/secondary_ranges/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: secondary_ranges
depends:
- name: inspec-gcp
Expand Down
14 changes: 14 additions & 0 deletions test/integration/simple_project/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: simple_project
depends:
- name: inspec-gcp
Expand Down
14 changes: 14 additions & 0 deletions test/integration/simple_project_with_regional_network/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: simple_project_with_regional_network
depends:
- name: inspec-gcp
Expand Down
14 changes: 14 additions & 0 deletions test/integration/submodule_firewall/inspec.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2021 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.

name: submodule_firewall
depends:
- name: inspec-gcp
Expand Down
Loading

0 comments on commit 56b03fe

Please sign in to comment.