terraspace
terraspace copied to clipboard
Terraspace seed error with one-line variable declaration
Also reported in hcl_parser#3
Checklist
- [ ] Upgrade Terraspace: Are you using the latest version of Terraspace? This allows Terraspace to fix issues fast. There's an Upgrading Guide: https://terraspace.cloud/docs/misc/upgrading/
- [ x] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
- [ x] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
My Environment
Software | Version |
---|---|
Operating System | Ubuntu 20.04LTS |
Terraform | v1.1.3 |
Terraspace | 1.0.0 |
Ruby | 3.0.3 |
Expected Behaviour
Seed command should produce a tfvars file
Current Behavior
Terraspace seed command fails when variables.tf contains a one-line variable declaration
Step-by-step reproduction instructions
-
terraspace new stack bob
- Edit app/stacks/bob/variables.tf
variable "var_0" {}
variable "var_n" {}
-
TS_ENV=alice terraspace seed bob
Results in error message:
hcl_parser-0.2.1/lib/hcl_parser/loader.rb:56:in `block in rewrite_complex_types': bad value for range (ArgumentError)
Error appears to be the logic that assumes the closing brace of a variable will be the first char on a line, because the following variables.tf results in no error when the seed command is run:
# app/stacks/bob/variables.tf
variable "var_0" {}
variable "var_n" {
}
Solution Suggestion
Modify hcl_parser/loader.rb to match a closing brace anywhere on a line in variables.tf
hi, we are experiencing this issue as well and confirm that the workaround for our variables.tf allows us to generate a tfvars.
Fixed in https://github.com/boltops-tools/hcl_parser/pull/5 To use, update the hcl_parser gem to 0.2.2. In your terraspace project
bundle update hcl_parser
This updates the Gemfile.lock
pin of hcl_parser. You'll need at least hcl_parser 0.2.2