Replies: 1 comment
-
Hi, The problem is related to local variables. In terraform and terragrunt, the same HCL language is used where we can use the locals {
project = "placeholder-value"
clusters = {
"1" = {
name = "app-us-central1-a-dev"
type = "app"
location = "us-central1-a"
}
"2" = {
name = "app-us-east4-a-dev"
type = "app"
location = "us-east4-a"
}
"3" = {
name = "twingate-dev-relays-us-1"
type = "relay"
location = "us-central1-b"
}
}
}
generate "flux" {
path = "flux.tf"
if_exists = "overwrite"
contents = templatefile("flux.tmpl", {
clusters = local.clusters
project_id = local.project
})
}
%{ for cluster_id, cluster in clusters ~}
module "cluster_${cluster_id}" {
source = "../../k8s"
cluster_name = "${cluster.name}"
project_id = "${project_id}"
cluster_location = "${cluster.location}"
}
%{ endfor ~} Executing # Generated by Terragrunt.
module "cluster_1" {
source = "../../k8s"
cluster_name = "app-us-central1-a-dev"
project_id = "dummy-value"
cluster_location = "us-central1-a"
}
module "cluster_2" {
source = "../../k8s"
cluster_name = "app-us-east4-a-dev"
project_id = "dummy-value"
cluster_location = "us-east4-a"
}
module "cluster_3" {
source = "../../k8s"
cluster_name = "twingate-dev-relays-us-1"
project_id = "dummy-value"
cluster_location = "us-central1-b"
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to generate a few module invocations
( i cant use the for_each for the module , since it uses a provider that does not support it )
So i thought of doing something like that
and in the template
so of course that
input.clusters
is not valid , so i am not sure how to provide the input data to the templateTracked in ticket #110609
Beta Was this translation helpful? Give feedback.
All reactions