0xDones / tfgen

Terraform code generator for consistent codebase and DRY
GNU General Public License v3.0
81 stars 12 forks source link

Unable to Template when building from Latest #9

Closed jseiser closed 1 year ago

jseiser commented 1 year ago
❯ git clone --depth 1 git@github.com:refl3ction/tfgen.git
Cloning into 'tfgen'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 17 (delta 1), reused 16 (delta 1), pack-reused 0
Receiving objects: 100% (17/17), 22.55 KiB | 1.50 MiB/s, done.
Resolving deltas: 100% (1/1), done.
  ~/repos                                                                                                                                                                                                                      02:37:47 PM
❯ cd tfgen
  ~/repos/tfgen   main                                                                                                                                                                                                       02:37:51 PM
❯ docker run --rm -v $PWD:/src -w /src -e GOOS=linux -e GOARCH=amd64 golang:alpine go build -o bin/tfgen

Same error if I clone, and just build directly with go as well

Leads to these errors, with a already working setup.

] ConfigFileDir:/home/justin/company/company_beta_infra}
2:43PM DBG writing template file: /home/justin/company/company_beta_infra/dev/deploys/jls/_remote.tf
2:43PM ERR failed to execute templates error="template: /home/justin/company/company_beta_infra/dev/deploys/jls/_remote.tf:4:51: executing \"/home/justin/company/company_beta_infra/dev/deploys/jls/_remote.tf\" at <.aws_account_id>: can't evaluate field aws_account_id in type tfgen.TemplateContext"
2:43PM DBG writing template file: /home/justin/company/company_beta_infra/dev/deploys/jls/_remote_dmz.tf
2:43PM ERR failed to execute templates error="template: /home/justin/company/company_beta_infra/dev/deploys/jls/_remote_dmz.tf:4:51: executing \"/home/justin/company/company_beta_infra/dev/deploys/jls/_remote_dmz.tf\" at <.aws_account_id>: can't evaluate field aws_account_id in type tfgen.TemplateContext"
2:43PM DBG writing template file: /home/justin/company/company_beta_infra/dev/deploys/jls/_versions.tf
2:43PM DBG writing template file: /home/justin/company/company_beta_infra/dev/deploys/jls/_backend.tf
2:43PM ERR failed to execute templates error="template: /home/justin/company/company_beta_infra/dev/deploys/jls/_backend.tf:2:25: executing \"/home/justin/company/company_beta_infra/dev/deploys/jls/_backend.tf\" at <.tf_version>: can't evaluate field tf_version in type tfgen.TemplateContext"
2:43PM DBG writing template file: /home/justin/company/company_beta_infra/dev/deploys/jls/_data.tf
2:43PM ERR failed to execute templates error="template: /home/justin/company/company_beta_infra/dev/deploys/jls/_data.tf:8:33: executing \"/home/justin/company/company_beta_infra/dev/deploys/jls/_data.tf\" at <.env>: can't evaluate field env in type tfgen.TemplateContext"
2:43PM DBG writing template file: /home/justin/company/company_beta_infra/dev/deploys/jls/_common.tf
2:43PM ERR failed to execute templates error="template: /home/justin/company/company_beta_infra/dev/deploys/jls/_common.tf:2:21: executing \"/home/justin/company/company_beta_infra/dev/deploys/jls/_common.tf\" at <.env>: can't evaluate field env in type tfgen.TemplateContext"
2:43PM DBG writing template file: /home/justin/company/company_beta_infra/dev/deploys/jls/_provider.tf
2:43PM ERR failed to execute templates error="template: /home/justin/company/company_beta_infra/dev/deploys/jls/_provider.tf:2:15: executing \"/home/justin/company/company_beta_infra/dev/deploys/jls/_provider.tf\" at <.aws_region>: can't evaluate field aws_region in type tfgen.TemplateContext"
2:43PM DBG deleting file: /home/justin/company/company_beta_infra/dev/deploys/jls/_versions.tf
2:43PM DBG deleting file: /home/justin/company/company_beta_infra/dev/deploys/jls/_backend.tf
2:43PM DBG deleting file: /home/justin/company/company_beta_infra/dev/deploys/jls/_data.tf
2:43PM DBG deleting file: /home/justin/company/company_beta_infra/dev/deploys/jls/_common.tf
2:43PM DBG deleting file: /home/justin/company/company_beta_infra/dev/deploys/jls/_provider.tf
2:43PM DBG deleting file: /home/justin/company/company_beta_infra/dev/deploys/jls/_remote.tf
2:43PM DBG deleting file: /home/justin/company/company_beta_infra/dev/deploys/jls/_remote_dmz.tf
2:43PM FTL error="failed to generate one or more templates, please check your configuration"

If i put back my old bin, it works fine.

jseiser commented 1 year ago

I had another person try this, and same result.

We are both linux if that would matter.

0xDones commented 1 year ago

Hi @jseiser , I think this is happening because I changed some things in the latest release, all the vars used in the template were moved to the .Vars object.

jseiser commented 1 year ago

@refl3ction

That was it, im going to create two issues, 1 for a changelog, and 1 for semantic versioning.

Thanks.