tofu-controller icon indicating copy to clipboard operation
tofu-controller copied to clipboard

gitops dependency do not work

Open marcobarducci opened this issue 3 years ago • 4 comments

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

marcobarducci avatar Nov 11 '22 23:11 marcobarducci

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

chanwit avatar Nov 13 '22 07:11 chanwit

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"}

marcobarducci avatar Nov 14 '22 18:11 marcobarducci

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?

chanwit avatar Nov 15 '22 07:11 chanwit

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.

marcobarducci avatar Nov 18 '22 08:11 marcobarducci