Skip to content

Commit

Permalink
Merge pull request #47 from terraform-google-modules/aaron-lane-0.12
Browse files Browse the repository at this point in the history
Add support for Terraform v0.12
  • Loading branch information
aaron-lane authored Jul 11, 2019
2 parents d1b6646 + 2b00adc commit 7ba1b23
Show file tree
Hide file tree
Showing 96 changed files with 611 additions and 425 deletions.
2 changes: 1 addition & 1 deletion .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning][semver-site].

## [Unreleased]

## [1.0.0] - 2019-06-ZZ

### Changed

- Supported version of Terraform is 0.12.

## [0.8.0] - 2019-06-12

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

[Unreleased]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.8.0...HEAD
[Unreleased]: https://github.com/terraform-google-modules/terraform-google-network/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.8.0...v1.0.0
[0.8.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/terraform-google-modules/terraform-google-network/compare/v0.5.0...v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ruby '2.5.3'
ruby '2.6.3'

source 'https://rubygems.org/' do
gem 'kitchen-terraform', '~> 4.3'
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@
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.
limitations under the License.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018 Google LLC
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@ SHELL := /usr/bin/env bash
# Docker build config variables
CREDENTIALS_PATH ?= /cft/workdir/credentials.json
DOCKER_ORG := gcr.io/cloud-foundation-cicd
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 0.11.10_216.0.0_1.19.1_0.1.10
DOCKER_TAG_BASE_KITCHEN_TERRAFORM ?= 2.0.0
DOCKER_REPO_BASE_KITCHEN_TERRAFORM := ${DOCKER_ORG}/cft/kitchen-terraform:${DOCKER_TAG_BASE_KITCHEN_TERRAFORM}

# All is the first target in the file so it will get picked up when you just run 'make' on its own
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ It supports creating:
- Subnets within the VPC
- Secondary ranges for the subnets (if applicable)

## 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).

## Usage
You can go to the examples folder, however the usage of the module could be like this in your own main.tf file:

```hcl
module "vpc" {
source = "terraform-google-modules/network/google"
version = "0.6.0"
version = "~> 1.0.0"
project_id = "<PROJECT ID>"
network_name = "example-vpc"
Expand Down Expand Up @@ -73,20 +77,19 @@ Then perform the following commands on the root folder:
- `terraform apply` to apply the infrastructure build
- `terraform destroy` to destroy the built infrastructure

[^]: (autogen_docs_start)

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| 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 |
| network\_name | The name of the network being created | string | n/a | yes |
| project\_id | The ID of the project where this VPC will be created | string | n/a | yes |
| routes | List of routes being created in this VPC | list | `<list>` | no |
| routes | List of routes being created in this VPC | list(map(string)) | `<list>` | no |
| routing\_mode | The network routing mode (default 'GLOBAL') | string | `"GLOBAL"` | no |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | map | n/a | yes |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | object | n/a | yes |
| shared\_vpc\_host | Makes this project a Shared VPC host if 'true' (default 'false') | string | `"false"` | no |
| subnets | The list of subnets being created | list | n/a | yes |
| subnets | The list of subnets being created | list(map(string)) | n/a | yes |

## Outputs

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

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

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

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

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

- Compute Engine API - compute.googleapis.com

## Install

### Terraform
Be sure you have the correct Terraform version (0.10.x), you can choose the binary here:
- https://releases.hashicorp.com/terraform/

## File structure
The project has the following folders and files:

Expand Down Expand Up @@ -230,3 +227,5 @@ is a compiled language so there is no standard linter.
* Terraform - terraform has a built-in linter in the 'terraform validate'
command.
* Dockerfiles - hadolint. Can be found in homebrew

[terraform-provider-google]: https://github.com/terraform-providers/terraform-provider-google
16 changes: 8 additions & 8 deletions codelabs/simple/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@ module "vpc" {
version = "~> 0.4.0"

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

subnets = [
Expand Down Expand Up @@ -67,7 +67,7 @@ resource "random_id" "instance_id" {
# Launch a VM on it
resource "google_compute_instance" "default" {
name = "vm-${random_id.instance_id.hex}"
project = "${google_project_service.compute.project}"
project = google_project_service.compute.project
machine_type = "f1-micro"
zone = "us-west1-a"

Expand All @@ -78,8 +78,8 @@ resource "google_compute_instance" "default" {
}

network_interface {
subnetwork = "${module.vpc.subnets_names[0]}"
subnetwork_project = "${google_project_service.compute.project}"
subnetwork = module.vpc.subnets_names[0]
subnetwork_project = google_project_service.compute.project

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

allow {
protocol = "icmp"
Expand All @@ -106,5 +106,5 @@ resource "google_compute_firewall" "allow-ping" {
}

output "ip" {
value = "${google_compute_instance.default.network_interface.0.access_config.0.nat_ip}"
value = google_compute_instance.default.network_interface.0.access_config.0.nat_ip
}
5 changes: 2 additions & 3 deletions examples/delete_default_gateway_routes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ This example configures a single simple VPC inside of a project.

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

[^]: (autogen_docs_start)

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs

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

[^]: (autogen_docs_end)
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
16 changes: 12 additions & 4 deletions examples/delete_default_gateway_routes/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,19 +14,27 @@
* limitations under the License.
*/

provider "google" {
version = "~> 2.10.0"
}

provider "null" {
version = "~> 2.1"
}

locals {
subnet_01 = "${var.network_name}-subnet-01"
}

module "test-vpc-module" {
source = "../../"
project_id = "${var.project_id}"
network_name = "${var.network_name}"
project_id = var.project_id
network_name = var.network_name
delete_default_internet_gateway_routes = "true"

subnets = [
{
subnet_name = "${local.subnet_01}"
subnet_name = local.subnet_01
subnet_ip = "10.20.30.0/24"
subnet_region = "us-west1"
},
Expand Down
20 changes: 10 additions & 10 deletions examples/delete_default_gateway_routes/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,46 +15,46 @@
*/

output "network_name" {
value = "${module.test-vpc-module.network_name}"
value = module.test-vpc-module.network_name
description = "The name of the VPC being created"
}

output "network_self_link" {
value = "${module.test-vpc-module.network_self_link}"
value = module.test-vpc-module.network_self_link
description = "The URI of the VPC being created"
}

output "subnets_names" {
value = "${module.test-vpc-module.subnets_names}"
value = module.test-vpc-module.subnets_names
description = "The names of the subnets being created"
}

output "subnets_ips" {
value = "${module.test-vpc-module.subnets_ips}"
value = module.test-vpc-module.subnets_ips
description = "The IP and cidrs of the subnets being created"
}

output "subnets_regions" {
value = "${module.test-vpc-module.subnets_regions}"
value = module.test-vpc-module.subnets_regions
description = "The region where subnets will be created"
}

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

output "subnets_flow_logs" {
value = "${module.test-vpc-module.subnets_flow_logs}"
value = module.test-vpc-module.subnets_flow_logs
description = "Whether the subnets will have VPC flow logs enabled"
}

output "subnets_secondary_ranges" {
value = "${module.test-vpc-module.subnets_secondary_ranges}"
value = module.test-vpc-module.subnets_secondary_ranges
description = "The secondary ranges associated with these subnets"
}

output "routes" {
value = "${module.test-vpc-module.routes}"
value = module.test-vpc-module.routes
description = "The routes associated with this VPC"
}
2 changes: 1 addition & 1 deletion examples/delete_default_gateway_routes/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
19 changes: 19 additions & 0 deletions examples/delete_default_gateway_routes/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright 2019 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.
*/

terraform {
required_version = "~> 0.12.0"
}
5 changes: 2 additions & 3 deletions examples/multi_vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

This example configures a host network project with two separate networks.

[^]: (autogen_docs_start)

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs

| Name | Description | Type | Default | Required |
Expand Down Expand Up @@ -35,4 +34,4 @@ This example configures a host network project with two separate networks.
| network\_02\_subnets\_regions | The region where the subnets will be created on network-02 |
| network\_02\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets on network-02 |

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

0 comments on commit 7ba1b23

Please sign in to comment.