From 1a8215dbbd1c894f82d5937a05526d6fb01790e4 Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Thu, 10 Jan 2019 17:18:00 -0500 Subject: [PATCH 1/3] Remove secondary range from simple example --- examples/simple_project/main.tf | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/simple_project/main.tf b/examples/simple_project/main.tf index f2f09b0c..17ead544 100644 --- a/examples/simple_project/main.tf +++ b/examples/simple_project/main.tf @@ -35,13 +35,7 @@ module "test-vpc-module" { ] secondary_ranges = { - subnet-01 = [ - { - range_name = "subnet-01-secondary-01" - ip_cidr_range = "192.168.64.0/24" - }, - ] - + subnet-01 = [] subnet-02 = [] } } From 7ed7464b26edbacfeae1e5522a2a56a03b7e0f96 Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Thu, 10 Jan 2019 17:21:21 -0500 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c17758..4597adff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,26 @@ -## 0.4.0 +## [Unreleased] +### Fixed +- Resolved issue with networks that have no secondary networks (#19) +## 0.4.0 +### Changed - Make `subnet_private_access` and `subnet_flow_logs` into strings to be consistent with `shared_vpc` flag (#13) ## 0.3.0 - +### Added - Add support for controlling subnet flow logs (#6) + +### Changed - Make `subnet_private_access` default to false (#6) ## 0.2.0 - +### Added - Add support for Shared VPC hosting ## 0.1.0 -This is the initial release of the module, with basic support for creating: - +### Added +- Initial release - A Google Virtual Private Network (VPC) - Subnets within the VPC - Secondary ranges for the subnets (if applicable) From f251cf8650980e887241ab468feb3a58f7a90121 Mon Sep 17 00:00:00 2001 From: Adrien Thebo Date: Fri, 11 Jan 2019 11:49:20 -0800 Subject: [PATCH 3/3] Add example with single VPC and more complex secondary networks --- examples/secondary_ranges/README.md | 30 +++++++++++++ examples/secondary_ranges/main.tf | 61 ++++++++++++++++++++++++++ examples/secondary_ranges/outputs.tf | 60 +++++++++++++++++++++++++ examples/secondary_ranges/variables.tf | 19 ++++++++ 4 files changed, 170 insertions(+) create mode 100644 examples/secondary_ranges/README.md create mode 100644 examples/secondary_ranges/main.tf create mode 100644 examples/secondary_ranges/outputs.tf create mode 100644 examples/secondary_ranges/variables.tf diff --git a/examples/secondary_ranges/README.md b/examples/secondary_ranges/README.md new file mode 100644 index 00000000..78a33b63 --- /dev/null +++ b/examples/secondary_ranges/README.md @@ -0,0 +1,30 @@ +# Secondary Ranges + +This example configures a single simple VPC inside of a project. + +This VPC has three subnets, with the first subnet being given two secondary +ranges and the third being given a single secondary range. + +[^]: (autogen_docs_start) + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| project\_id | The project ID to host the network in | string | - | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| network\_name | The name of the VPC being created | +| network\_self\_link | The URI of the VPC being created | +| routes | The routes associated with this VPC | +| subnets\_flow\_logs | Whether the subnets will have VPC flow logs enabled | +| subnets\_ips | The IP and cidrs of the subnets being created | +| subnets\_names | The names of the subnets being created | +| subnets\_private\_access | Whether the subnets will have access to Google API's without a public IP | +| subnets\_regions | The region where subnets will be created | +| subnets\_secondary\_ranges | The secondary ranges associated with these subnets | + +[^]: (autogen_docs_end) diff --git a/examples/secondary_ranges/main.tf b/examples/secondary_ranges/main.tf new file mode 100644 index 00000000..da2fdd89 --- /dev/null +++ b/examples/secondary_ranges/main.tf @@ -0,0 +1,61 @@ +/** + * Copyright 2018 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. + */ + +module "vpc-secondary-ranges" { + source = "../../" + project_id = "${var.project_id}" + network_name = "vpc-secondary-ranges" + + subnets = [ + { + subnet_name = "secondary-ranges-subnet-01" + subnet_ip = "10.10.10.0/24" + subnet_region = "us-west1" + }, + { + subnet_name = "secondary-ranges-subnet-02" + subnet_ip = "10.10.20.0/24" + subnet_region = "us-west1" + subnet_private_access = "true" + subnet_flow_logs = "true" + }, + { + subnet_name = "secondary-ranges-subnet-03" + subnet_ip = "10.10.30.0/24" + subnet_region = "us-west1" + }, + ] + + secondary_ranges = { + secondary-ranges-subnet-01 = [ + { + range_name = "subnet-01-01" + ip_cidr_range = "192.168.64.0/24" + }, + { + range_name = "subnet-01-02" + ip_cidr_range = "192.168.65.0/24" + }, + ] + secondary-ranges-subnet-02 = [] + secondary-ranges-subnet-03 = [ + { + range_name = "subnet-03-01" + ip_cidr_range = "192.168.66.0/24" + }, + ] + } +} diff --git a/examples/secondary_ranges/outputs.tf b/examples/secondary_ranges/outputs.tf new file mode 100644 index 00000000..d1c7ad47 --- /dev/null +++ b/examples/secondary_ranges/outputs.tf @@ -0,0 +1,60 @@ +/** + * Copyright 2018 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. + */ + +output "network_name" { + value = "${module.vpc-secondary-ranges.network_name}" + description = "The name of the VPC being created" +} + +output "network_self_link" { + value = "${module.vpc-secondary-ranges.network_self_link}" + description = "The URI of the VPC being created" +} + +output "subnets_names" { + value = "${module.vpc-secondary-ranges.subnets_names}" + description = "The names of the subnets being created" +} + +output "subnets_ips" { + value = "${module.vpc-secondary-ranges.subnets_ips}" + description = "The IP and cidrs of the subnets being created" +} + +output "subnets_regions" { + value = "${module.vpc-secondary-ranges.subnets_regions}" + description = "The region where subnets will be created" +} + +output "subnets_private_access" { + value = "${module.vpc-secondary-ranges.subnets_private_access}" + description = "Whether the subnets will have access to Google API's without a public IP" +} + +output "subnets_flow_logs" { + value = "${module.vpc-secondary-ranges.subnets_flow_logs}" + description = "Whether the subnets will have VPC flow logs enabled" +} + +output "subnets_secondary_ranges" { + value = "${flatten(module.vpc-secondary-ranges.subnets_secondary_ranges)}" + description = "The secondary ranges associated with these subnets" +} + +output "routes" { + value = "${module.vpc-secondary-ranges.routes}" + description = "The routes associated with this VPC" +} diff --git a/examples/secondary_ranges/variables.tf b/examples/secondary_ranges/variables.tf new file mode 100644 index 00000000..b69e2b2e --- /dev/null +++ b/examples/secondary_ranges/variables.tf @@ -0,0 +1,19 @@ +/** + * Copyright 2018 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. + */ + +variable "project_id" { + description = "The project ID to host the network in" +}