Skip to content

Commit

Permalink
vshn-lbaas-cloudscale: Add variables to control which cloudscale floa…
Browse files Browse the repository at this point in the history
…ting IPs are allocated
  • Loading branch information
simu committed Jul 16, 2024
1 parent fd0e901 commit 1dab344
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions modules/vshn-lbaas-cloudscale/hiera.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module "hiera" {
ingress_controller = var.ingress_controller
lb_names = random_id.lb[*].hex
hieradata_repo_user = var.hieradata_repo_user
api_vip = cidrhost(local.api_vip[0].network, 0)
api_vip = var.enable_api_vip ? cidrhost(local.api_vip[0].network, 0) : ""
internal_vip = var.internal_vip
nat_vip = cidrhost(local.nat_vip[0].network, 0)
router_vip = cidrhost(local.router_vip[0].network, 0)
nat_vip = var.enable_nat_vip ? cidrhost(local.nat_vip[0].network, 0) : ""
router_vip = var.enable_router_vip ? cidrhost(local.router_vip[0].network, 0) : ""
team = var.team
enable_proxy_protocol = var.enable_proxy_protocol

Expand Down
6 changes: 3 additions & 3 deletions modules/vshn-lbaas-cloudscale/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "cloudscale_floating_ip" "api_vip" {
count = var.lb_count != 0 && !var.use_existing_vips ? 1 : 0
count = var.lb_count != 0 && !var.use_existing_vips && var.enable_api_vip ? 1 : 0
ip_version = 4
region_slug = var.region
reverse_ptr = "api.${var.node_name_suffix}"
Expand All @@ -20,7 +20,7 @@ data "cloudscale_floating_ip" "api_vip" {
}

resource "cloudscale_floating_ip" "router_vip" {
count = var.lb_count != 0 && !var.use_existing_vips ? 1 : 0
count = var.lb_count != 0 && !var.use_existing_vips && var.enable_router_vip ? 1 : 0
ip_version = 4
region_slug = var.region
reverse_ptr = "ingress.${var.node_name_suffix}"
Expand All @@ -41,7 +41,7 @@ data "cloudscale_floating_ip" "router_vip" {
}

resource "cloudscale_floating_ip" "nat_vip" {
count = var.lb_count != 0 && !var.use_existing_vips ? 1 : 0
count = var.lb_count != 0 && !var.use_existing_vips && var.enable_nat_vip ? 1 : 0
ip_version = 4
region_slug = var.region
reverse_ptr = "egress.${var.node_name_suffix}"
Expand Down
18 changes: 18 additions & 0 deletions modules/vshn-lbaas-cloudscale/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,21 @@ variable "use_existing_vips" {
description = "Use existing floating IPs for api_vip, router_vip and nat_vip. Manually set the reverse DNS info, so the correct data source is found."
default = false
}

variable "enable_api_vip" {
type = bool
description = "Whether to configure a cloudscale floating IP for the API"
default = true
}

variable "enable_router_vip" {
type = bool
description = "Whether to configure a cloudscale floating IP for the router"
default = true
}

variable "enable_nat_vip" {
type = bool
description = "Whether to configure a cloudscale floating IP for the default gateway NAT"
default = true
}

0 comments on commit 1dab344

Please sign in to comment.