Skip to content

Commit

Permalink
Added conditional master authorized networks
Browse files Browse the repository at this point in the history
  • Loading branch information
davinerd committed Jul 4, 2021
1 parent 994e66a commit de6fe67
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
locals {
master_authorized_networks = [
local_authorized_network = [
{
cidr_block = "${chomp(data.http.my_public_ip.body)}/32",
display_name = "My public IP"
}
]

# THE FOLLOWING CODE IS REPORTED HERE JUST AS REFERENCE
# Check if we passed down a map or just a list of IPs
# master_networks_key_exists = contains(keys(var.master_authorized_networks), "cidr_block") <- doesn't work since var.master_authorized_networks must be known before apply
# global_master_networks = local.master_networks_key_exists ? var.master_authorized_networks : [for ip in var.master_authorized_networks: tomap({cidr_block = ip, display_name = "Custom IP"})]
# Build the actual authorized networks list
# master_authorized_networks = var.master_authorized_networks == [] ? local.local_authorized_network : local.global_master_networks

master_authorized_networks = length(var.master_authorized_networks) == 0 ? local.local_authorized_network : var.master_authorized_networks

default_node_pools_labels = {
all = {
(var.node_pools_name) = true
Expand All @@ -14,7 +23,6 @@ locals {

node_pools_labels = var.node_pools_labels != {} ? var.node_pools_labels : local.default_node_pools_labels


default_node_pools_tains = {
all = [{
key = var.node_pools_name
Expand Down

0 comments on commit de6fe67

Please sign in to comment.