Open marcobarducci opened 1 year ago
Hi @marcobarducci
Yep, that's the behaviour of Kustomization controller.
Please annotate your certain Terraform objects with kustomize.toolkit.fluxcd.io/substitute: disabled
to avoid substitution.
https://fluxcd.io/flux/components/kustomize/kustomization/#variable-substitution
but why? i could have the need to give some variables in input and grab others from a module.
anyway i tried to create a variable "values", an object as you did into the primitive modules. if i pass a list of string it fails
{"level":"error","ts":"2022-11-14T18:20:45.240Z","logger":"runner.terraform","msg":"unable to marshal the data","instance-id":"f7badb91-4ac6-45cc-8c13-87d37180fd35","error":"json: error calling MarshalJSON for type *v1.JSON: invalid character 's' after object key:value pair"}
but why? i could have the need to give some variables in input and grab others from a module.
You can also use $$
to escape the $. Please refer to the Kustomization docs to do so.
Could you please post the example of how you did that?
our scenario is: we have terraformed our infrastructure stack in various modules. every module needs some variables as input and gives some outputs that can be used by another module. for example we define the network stack with a module and later an eks takes in input vpc_id, subnets ecc from the output of network module. this approach is the same used by the official terraform modules. tf-controller if i understood cannot manage variables like this approach but only a "value" object.
using this example: https://weaveworks.github.io/tf-controller/use_tf_controller/with_GitOps_dependency_management
it seems that it cannot work the variable substitution (as in the doc ${{ .aws_s3_bucket.bucket }}) and for this reason the flux kustomization breaks
variable substitution failed: unable to parse variable name