Skip to content

Commit 3faabdb

Browse files
committed
validation and connection change
1 parent cda7da7 commit 3faabdb

File tree

7 files changed

+38
-9
lines changed

7 files changed

+38
-9
lines changed

metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
source:
2525
repo: https://github.com/terraform-google-modules/terraform-google-cloud-router.git
2626
sourceType: git
27-
version: 7.4.4
27+
version: 7.4.5
2828
actuationTool:
2929
flavor: Terraform
3030
version: ">= 1.3"

modules/interconnect_attachment/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-cloud-router.git
2626
sourceType: git
2727
dir: /modules/interconnect_attachment
28-
version: 7.4.4
28+
version: 7.4.5
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">= 1.3"

modules/interconnect_attachment/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ terraform {
2626
}
2727

2828
provider_meta "google" {
29-
module_name = "blueprints/terraform/terraform-google-cloud-router:interconnect_attachment/v7.4.4"
29+
module_name = "blueprints/terraform/terraform-google-cloud-router:interconnect_attachment/v7.4.5"
3030
}
3131
}

modules/interface/main.tf

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2020 Google LLC
2+
* Copyright 2025 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,6 +14,29 @@
1414
* limitations under the License.
1515
*/
1616

17+
locals {
18+
has_ip_range = var.ip_range != null
19+
has_vpn_tunnel = var.vpn_tunnel != null
20+
has_interconnect_attachment = var.interconnect_attachment != null
21+
22+
# True if exactly one of vpn_tunnel or interconnect_attachment is set
23+
exactly_one_link_type = ((local.has_vpn_tunnel ? 1 : 0) + (local.has_interconnect_attachment ? 1 : 0)) == 1
24+
}
25+
26+
# Validation Resource: Enforces the connection type rules
27+
resource "null_resource" "interface_connection_validation" {
28+
lifecycle {
29+
precondition {
30+
condition = (
31+
(local.has_ip_range && !local.has_vpn_tunnel && !local.has_interconnect_attachment) ||
32+
(!local.has_ip_range && local.exactly_one_link_type) ||
33+
(local.has_ip_range && local.exactly_one_link_type)
34+
)
35+
error_message = "Invalid argument combination for router interface. Please provide: (1) only ip_range, OR (2) exactly one of (vpn_tunnel, interconnect_attachment), OR (3) ip_range AND exactly one of (vpn_tunnel, interconnect_attachment)."
36+
}
37+
}
38+
}
39+
1740
resource "google_compute_router_interface" "interface" {
1841
name = var.name
1942
project = var.project_id

modules/interface/metadata.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
repo: https://github.com/terraform-google-modules/terraform-google-cloud-router.git
2626
sourceType: git
2727
dir: /modules/interface
28-
version: 7.4.4
28+
version: 7.4.5
2929
actuationTool:
3030
flavor: Terraform
3131
version: ">= 1.3"
@@ -54,8 +54,8 @@ spec:
5454
required: true
5555
connections:
5656
- source:
57-
source: github.com/terraform-google-modules/terraform-google-cloud-router
58-
version: ">= 7.4.0"
57+
source: github.com/yuktatechgog/terraform-google-cloud-router
58+
version: ">= 7.4.5"
5959
spec:
6060
outputExpr: router.name
6161
- source:
@@ -120,3 +120,5 @@ spec:
120120
providerVersions:
121121
- source: hashicorp/google
122122
version: ">= 5.12, < 8"
123+
- source: hashicorp/null
124+
version: ~> 3.2

modules/interface/versions.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ terraform {
2222
source = "hashicorp/google"
2323
version = ">= 5.12, < 8"
2424
}
25+
null = {
26+
source = "hashicorp/null"
27+
version = "~> 3.2"
28+
}
2529
}
2630

2731
provider_meta "google" {
28-
module_name = "blueprints/terraform/terraform-google-cloud-router:interface/v7.4.4"
32+
module_name = "blueprints/terraform/terraform-google-cloud-router:interface/v7.4.5"
2933
}
3034
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ terraform {
2525
}
2626

2727
provider_meta "google" {
28-
module_name = "blueprints/terraform/terraform-google-cloud-router/v7.4.4"
28+
module_name = "blueprints/terraform/terraform-google-cloud-router/v7.4.5"
2929
}
3030

3131
}

0 commit comments

Comments
 (0)