I have some very simple code to do some testing with and I am running into some issues. My overall goal is to have config stored in a .yaml file which I then use templatefile to replace some variables and finally it will be jsonencoded.
main.tf
locals {
test = yamldecode(templatefile("${path.module}/test.yaml",
{
admin_groups = ["123456-7890"]
}
))
}
output "test" {
value = jsonencode(local.test)
}
test.yaml
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails['omniauth_providers'] = |
admin_groups: ['${admin_groups}']
When terraform plan however I am getting the following error message:
│ Error: Error in function call
│
│ on main.tf line 2, in locals:
│ 2: test = yamldecode(templatefile("${path.module}/test.yaml",
│ 3: {
│ 4: admin_groups = ["123456-7890"]
│ 5: }
│ 6: ))
│ ├────────────────
│ │ path.module is "."
│
│ Call to function "templatefile" failed: ./test.yaml:3,25-37: Invalid template interpolation value; Cannot include the given value in a string template: string required..
Is there some way to interpolate this list of strings that I am not doing? Cheers for any help.