terramate-io / terramate

Terramate CLI is an open-source Infrastructure as Code (IaC) Orchestration and Code Generation tool for Terraform, OpenTofu and Terragrunt.

Home Page:https://terramate.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Cloning fails if a stack has imports configured

soerenmartius opened this issue · comments

Describe the bug
If users try to clone a stack using terramate experimental clone stacks/a stacks/b, it will fail if stack-a contains import configuration such as

imports {
  sources = "/modules/some_generate.hcl"
}
Screenshot 2024-01-25 at 19 40 38

To Reproduce

Clone the following repository: https://github.com/terramate-io/terramate-quickstart-aws/pull/2/files
Run terramate experimental clone stacks/a stacks/b

Expected behavior
The import statement should work as expected if an absolute path is provided or a relative path gets cloned to the same level of the directory hierarchy.

Log Output
Add logs from Terramate to help debug your problem.

Environment (please complete the following information):

  • OS: MacOS
  • OS Version 14.3 (23D56)
  • Git Version 2.43.0
  • Terramate Version 0.4.4

I was curious if adding imports to "stack.tm.hcl" was the Terramate convention (vs say creating an "imports.tm.hcl"). I see that terramate create --import /lib/stacks/foobar.tm.hcl ./stacks/production/foo does add the imports to "stack.tm.hcl". I realize both work but wanted to investigate a bit before rewriting all my imports so I can use "clone" until this is resolved. ;)

@emiel, both are valid approaches. At run time all tm.hcl files are merged into a single file anyways. So if you decide to fan out into multiple files, it won't change anything other than perhaps readability.

commented

This fix was released in v0.6.0