boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
678 stars 46 forks source link

Variables usage is all but clear #273

Closed az-z closed 1 year ago

az-z commented 2 years ago

Hello, the usage of env and terrspace vars in the application needs clarity: For example:

  1. How can env var be used in stack tf files?
  2. How can env variable be used in terraform.tfvars file?
  3. How terraspace specific variables can be accessed in stacks tf files and tfvars?
  4. What is the rule for using a single vs double quote symbol when referencing a variable?

Here are the examples: config/app.rb:

Terraspace.configure do |config|
  config.cloud.project = "InfraIAC" 
end

stack/demo/terraform.tfvars:

aws_region = "<%= expansion(':ENV') %>"
client_abbr = "<%= expansion(":CLIENT_ABBR") %>"
project_abbr = "<%= expansion(':APP') %>"

cached version:

aws_region = "dev"
client_abbr = ":CLIENT_ABBR"
project_abbr = ""
  1. Consistency in accessing vars: Can't locate at the moment, but in some parts of the documentation access to vars is:
    ENV['FOO']

    at others :

    "<%= expansion(':ENV') %>"

    when to use what is not obvious and not clearly documented.

Not a documentation, but a usage impediment:

the variables used in the code (.tf, rb and tfvars ) and their values should be printed during the "plan" stage, so that a user can inspect their value or absence of it.

tongueroo commented 1 year ago

Answered in https://community.boltops.com/t/variables-usage-is-all-but-clear/992/2