Good evening Infracosters, I was hoping someone co...
# help
d
Good evening Infracosters, I was hoping someone could help me and perhaps save my desk from having a headshaped dent in it. I have a terraform directory setup, which within contains
Copy code
- root
    |- > environment
            | - > dev.tfvars
            | - > prod.tfvars
    |-> *.tf
To islolate this in state, I'm using workspaces (without cloud), and I am using the Github action. However, I cannot for the life of me, get the infracost to pick up the workspace and use the correct tfvars as needed based on the workspace name.. Any advice or examples? I've done a lot of googling and either no one is doing this, its really simple or im doing something stupid and why would any one?
m
Hi @delightful-table-96636 yes Infracost should be able to support this
What does the output of
infracost generate config
look like when you run it in the root of your repo
d
Hi @mysterious-teacher-68276
Copy code
version: 0.1

projects:
  - path: .
    name: main-production
    terraform_var_files:
      - production/production.tfvars
    skip_autodetect: true
  - path: .
    name: main-staging
    terraform_var_files:
      - staging/staging.tfvars
    skip_autodetect: true
So the generate has picked up the required tfvars, would I just add this to the config in the root of the folder ; what about workspaces or are they not really needed in this context
m
yeah workspaces aren’t really needed by infracost unless you use terraform cloud and store your variables there. If the above output seems to reflect your project structure (which is seems like it does) then there’s nothing to do. the infracost
diff/breakdown
commands (run in the root of your repo) will autodetect the same projects (main/staging).
d
Winner, me over thinking and not taking a minute to calm down 🙂