Skip to content

Commit

Permalink
disable googleapi routes creation when vpc is not created (#1489)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludoo authored Jul 3, 2023
1 parent aeaf1f6 commit 86cc6ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/net-vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ module "vpc" {
| [name](variables.tf#L83) | The name of the network being created. | <code>string</code> | ✓ | |
| [project_id](variables.tf#L99) | The ID of the project where this VPC will be created. | <code>string</code> | ✓ | |
| [auto_create_subnetworks](variables.tf#L17) | Set to true to create an auto mode subnet, defaults to custom mode. | <code>bool</code> | | <code>false</code> |
| [create_googleapis_routes](variables.tf#L23) | Toggle creation of googleapis private/restricted routes. Set to null to disable creation. | <code title="object&#40;&#123;&#10; private &#61; optional&#40;bool, true&#41;&#10; private-6 &#61; optional&#40;bool, false&#41;&#10; restricted &#61; optional&#40;bool, true&#41;&#10; restricted-6 &#61; optional&#40;bool, false&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [create_googleapis_routes](variables.tf#L23) | Toggle creation of googleapis private/restricted routes. Disabled when vpc creation is turned off, or when set to null. | <code title="object&#40;&#123;&#10; private &#61; optional&#40;bool, true&#41;&#10; private-6 &#61; optional&#40;bool, false&#41;&#10; restricted &#61; optional&#40;bool, true&#41;&#10; restricted-6 &#61; optional&#40;bool, false&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>&#123;&#125;</code> |
| [data_folder](variables.tf#L34) | An optional folder containing the subnet configurations in YaML format. | <code>string</code> | | <code>null</code> |
| [delete_default_routes_on_create](variables.tf#L40) | Set to true to delete the default routes at creation time. | <code>bool</code> | | <code>false</code> |
| [description](variables.tf#L46) | An optional description of this resource (triggers recreation on change). | <code>string</code> | | <code>&#34;Terraform-managed.&#34;</code> |
Expand Down
5 changes: 4 additions & 1 deletion modules/net-vpc/routes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ locals {
priority = 1000
tags = null
}
if lookup(coalesce(var.create_googleapis_routes, {}), k, false)
if(
var.vpc_create &&
lookup(coalesce(var.create_googleapis_routes, {}), k, false)
)
}
_routes = merge(local._googleapis_routes, coalesce(var.routes, {}))
routes = {
Expand Down
2 changes: 1 addition & 1 deletion modules/net-vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable "auto_create_subnetworks" {
}

variable "create_googleapis_routes" {
description = "Toggle creation of googleapis private/restricted routes. Set to null to disable creation."
description = "Toggle creation of googleapis private/restricted routes. Disabled when vpc creation is turned off, or when set to null."
type = object({
private = optional(bool, true)
private-6 = optional(bool, false)
Expand Down

0 comments on commit 86cc6ee

Please sign in to comment.