Skip to content

Commit 7ba1b23

Browse files
authored
Merge pull request #47 from terraform-google-modules/aaron-lane-0.12
Add support for Terraform v0.12
2 parents d1b6646 + 2b00adc commit 7ba1b23

File tree

96 files changed

+611
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+611
-425
lines changed

.kitchen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Google LLC
1+
# Copyright 2019 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning][semver-site].
77

88
## [Unreleased]
99

10+
## [1.0.0] - 2019-06-ZZ
11+
12+
### Changed
13+
14+
- Supported version of Terraform is 0.12.
15+
1016
## [0.8.0] - 2019-06-12
1117

1218
### Added
@@ -80,7 +86,8 @@ and this project adheres to [Semantic Versioning][semver-site].
8086
- Subnets within the VPC
8187
- Secondary ranges for the subnets (if applicable)
8288

83-
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.8.0...HEAD
89+
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-network/compare/v1.0.0...HEAD
90+
[1.0.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.8.0...v1.0.0
8491
[0.8.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.7.0...v0.8.0
8592
[0.7.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.6.0...v0.7.0
8693
[0.6.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.5.0...v0.6.0

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Google LLC
1+
# Copyright 2019 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
ruby '2.5.3'
15+
ruby '2.6.3'
1616

1717
source 'https://rubygems.org/' do
1818
gem 'kitchen-terraform', '~> 4.3'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,4 @@
199199
distributed under the License is distributed on an "AS IS" BASIS,
200200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201201
See the License for the specific language governing permissions and
202-
limitations under the License.
202+
limitations under the License.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Google LLC
1+
# Copyright 2019 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ SHELL := /usr/bin/env bash
1818
# Docker build config variables
1919
CREDENTIALS_PATH ?= /cft/workdir/credentials.json
2020
DOCKER_ORG := gcr.io/cloud-foundation-cicd
21-
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 0.11.10_216.0.0_1.19.1_0.1.10
21+
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.0.0
2222
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}
2323

2424
# All is the first target in the file so it will get picked up when you just run 'make' on its own

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ It supports creating:
88
- Subnets within the VPC
99
- Secondary ranges for the subnets (if applicable)
1010

11+
## Compatibility
12+
13+
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).
14+
1115
## Usage
1216
You can go to the examples folder, however the usage of the module could be like this in your own main.tf file:
1317

1418
```hcl
1519
module "vpc" {
1620
source = "terraform-google-modules/network/google"
17-
version = "0.6.0"
21+
version = "~> 1.0.0"
1822
1923
project_id = "<PROJECT ID>"
2024
network_name = "example-vpc"
@@ -73,20 +77,19 @@ Then perform the following commands on the root folder:
7377
- `terraform apply` to apply the infrastructure build
7478
- `terraform destroy` to destroy the built infrastructure
7579

76-
[^]: (autogen_docs_start)
77-
80+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
7881
## Inputs
7982

8083
| Name | Description | Type | Default | Required |
8184
|------|-------------|:----:|:-----:|:-----:|
8285
| delete\_default\_internet\_gateway\_routes | If set, ensure that all routes within the network specified whose names begin with 'default-route' and with a next hop of 'default-internet-gateway' are deleted | string | `"false"` | no |
8386
| network\_name | The name of the network being created | string | n/a | yes |
8487
| project\_id | The ID of the project where this VPC will be created | string | n/a | yes |
85-
| routes | List of routes being created in this VPC | list | `<list>` | no |
88+
| routes | List of routes being created in this VPC | list(map(string)) | `<list>` | no |
8689
| routing\_mode | The network routing mode (default 'GLOBAL') | string | `"GLOBAL"` | no |
87-
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | map | n/a | yes |
90+
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | object | n/a | yes |
8891
| shared\_vpc\_host | Makes this project a Shared VPC host if 'true' (default 'false') | string | `"false"` | no |
89-
| subnets | The list of subnets being created | list | n/a | yes |
92+
| subnets | The list of subnets being created | list(map(string)) | n/a | yes |
9093

9194
## Outputs
9295

@@ -104,7 +107,7 @@ Then perform the following commands on the root folder:
104107
| subnets\_self\_links | The self-links of subnets being created |
105108
| svpc\_host\_project\_id | Shared VPC host project id. |
106109

107-
[^]: (autogen_docs_end)
110+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
108111

109112
### Subnet Inputs
110113
The subnets list contains maps, where each object represents a subnet. Each map has the following inputs (please see examples folder for additional references):
@@ -135,8 +138,8 @@ The routes list contains maps, where each object represents a route. For the nex
135138

136139
## Requirements
137140
### Installed Software
138-
- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
139-
- [terraform-provider-google](https://github.com/terraform-providers/terraform-provider-google) plugin v1.12.0
141+
- [Terraform](https://www.terraform.io/downloads.html) ~> 0.12.0
142+
- [Terraform Provider for GCP][terraform-provider-google] ~> 2.10.0
140143
- [gcloud](https://cloud.google.com/sdk/gcloud/) >243.0.0
141144

142145
### Configure a Service Account
@@ -154,12 +157,6 @@ In order to operate with the Service Account you must activate the following API
154157

155158
- Compute Engine API - compute.googleapis.com
156159

157-
## Install
158-
159-
### Terraform
160-
Be sure you have the correct Terraform version (0.10.x), you can choose the binary here:
161-
- https://releases.hashicorp.com/terraform/
162-
163160
## File structure
164161
The project has the following folders and files:
165162

@@ -230,3 +227,5 @@ is a compiled language so there is no standard linter.
230227
* Terraform - terraform has a built-in linter in the 'terraform validate'
231228
command.
232229
* Dockerfiles - hadolint. Can be found in homebrew
230+
231+
[terraform-provider-google]: https://github.com/terraform-providers/terraform-provider-google

codelabs/simple/main.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ module "vpc" {
2828
version = "~> 0.4.0"
2929

3030
# Give the network a name and project
31-
project_id = "${google_project_service.compute.project}"
31+
project_id = google_project_service.compute.project
3232
network_name = "my-custom-vpc-${random_id.network_id.hex}"
3333

3434
subnets = [
@@ -67,7 +67,7 @@ resource "random_id" "instance_id" {
6767
# Launch a VM on it
6868
resource "google_compute_instance" "default" {
6969
name = "vm-${random_id.instance_id.hex}"
70-
project = "${google_project_service.compute.project}"
70+
project = google_project_service.compute.project
7171
machine_type = "f1-micro"
7272
zone = "us-west1-a"
7373

@@ -78,8 +78,8 @@ resource "google_compute_instance" "default" {
7878
}
7979

8080
network_interface {
81-
subnetwork = "${module.vpc.subnets_names[0]}"
82-
subnetwork_project = "${google_project_service.compute.project}"
81+
subnetwork = module.vpc.subnets_names[0]
82+
subnetwork_project = google_project_service.compute.project
8383

8484
access_config {
8585
# Include this section to give the VM an external ip address
@@ -93,8 +93,8 @@ resource "google_compute_instance" "default" {
9393
# Allow traffic to the VM
9494
resource "google_compute_firewall" "allow-ping" {
9595
name = "default-ping"
96-
network = "${module.vpc.network_name}"
97-
project = "${google_project_service.compute.project}"
96+
network = module.vpc.network_name
97+
project = google_project_service.compute.project
9898

9999
allow {
100100
protocol = "icmp"
@@ -106,5 +106,5 @@ resource "google_compute_firewall" "allow-ping" {
106106
}
107107

108108
output "ip" {
109-
value = "${google_compute_instance.default.network_interface.0.access_config.0.nat_ip}"
109+
value = google_compute_instance.default.network_interface.0.access_config.0.nat_ip
110110
}

examples/delete_default_gateway_routes/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ This example configures a single simple VPC inside of a project.
44

55
This VPC has a single subnet with no secondary ranges, and ensures the default internet gateway route is deleted.
66

7-
[^]: (autogen_docs_start)
8-
7+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
98
## Inputs
109

1110
| Name | Description | Type | Default | Required |
@@ -27,4 +26,4 @@ This VPC has a single subnet with no secondary ranges, and ensures the default i
2726
| subnets\_regions | The region where subnets will be created |
2827
| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
2928

30-
[^]: (autogen_docs_end)
29+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/delete_default_gateway_routes/main.tf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,19 +14,27 @@
1414
* limitations under the License.
1515
*/
1616

17+
provider "google" {
18+
version = "~> 2.10.0"
19+
}
20+
21+
provider "null" {
22+
version = "~> 2.1"
23+
}
24+
1725
locals {
1826
subnet_01 = "${var.network_name}-subnet-01"
1927
}
2028

2129
module "test-vpc-module" {
2230
source = "../../"
23-
project_id = "${var.project_id}"
24-
network_name = "${var.network_name}"
31+
project_id = var.project_id
32+
network_name = var.network_name
2533
delete_default_internet_gateway_routes = "true"
2634

2735
subnets = [
2836
{
29-
subnet_name = "${local.subnet_01}"
37+
subnet_name = local.subnet_01
3038
subnet_ip = "10.20.30.0/24"
3139
subnet_region = "us-west1"
3240
},
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Google LLC
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,46 +15,46 @@
1515
*/
1616

1717
output "network_name" {
18-
value = "${module.test-vpc-module.network_name}"
18+
value = module.test-vpc-module.network_name
1919
description = "The name of the VPC being created"
2020
}
2121

2222
output "network_self_link" {
23-
value = "${module.test-vpc-module.network_self_link}"
23+
value = module.test-vpc-module.network_self_link
2424
description = "The URI of the VPC being created"
2525
}
2626

2727
output "subnets_names" {
28-
value = "${module.test-vpc-module.subnets_names}"
28+
value = module.test-vpc-module.subnets_names
2929
description = "The names of the subnets being created"
3030
}
3131

3232
output "subnets_ips" {
33-
value = "${module.test-vpc-module.subnets_ips}"
33+
value = module.test-vpc-module.subnets_ips
3434
description = "The IP and cidrs of the subnets being created"
3535
}
3636

3737
output "subnets_regions" {
38-
value = "${module.test-vpc-module.subnets_regions}"
38+
value = module.test-vpc-module.subnets_regions
3939
description = "The region where subnets will be created"
4040
}
4141

4242
output "subnets_private_access" {
43-
value = "${module.test-vpc-module.subnets_private_access}"
43+
value = module.test-vpc-module.subnets_private_access
4444
description = "Whether the subnets will have access to Google API's without a public IP"
4545
}
4646

4747
output "subnets_flow_logs" {
48-
value = "${module.test-vpc-module.subnets_flow_logs}"
48+
value = module.test-vpc-module.subnets_flow_logs
4949
description = "Whether the subnets will have VPC flow logs enabled"
5050
}
5151

5252
output "subnets_secondary_ranges" {
53-
value = "${module.test-vpc-module.subnets_secondary_ranges}"
53+
value = module.test-vpc-module.subnets_secondary_ranges
5454
description = "The secondary ranges associated with these subnets"
5555
}
5656

5757
output "routes" {
58-
value = "${module.test-vpc-module.routes}"
58+
value = module.test-vpc-module.routes
5959
description = "The routes associated with this VPC"
6060
}

0 commit comments

Comments
 (0)