Open n-my opened 3 months ago
It works opposite way,
you need to make condition in your template to generate only on stacks with tag aws
generate_hcl "_generate_main.tf" {
condition = tm_contains(terramate.stack.tags, "aws")
content {
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
}
}
then your terramate generate
will work
It works opposite way, you need to make condition in your template to generate only on stacks with tag
aws
generate_hcl "_generate_main.tf" { condition = tm_contains(terramate.stack.tags, "aws") content { resource "aws_vpc" "main" { cidr_block = "10.0.0.0/16" } } }
then your
terramate generate
will work
Thanks for answering this @bart-braidwell, I actually only saw this now. In addition to condition
you can also use stack_filter
such as repository_paths
and project_paths
.
This is pretty well documented in https://terramate.io/docs/cli/code-generation/generate-hcl
In addition to that, the code generation always run on the entire repository / Terramate project to prevent inconsistencies as there are plenty of factors that impact generated files such as globals, locals, etc. Partial code generation is not a good idea.
Describe the bug
To Reproduce
Create 2 stacks, only one with a tag
Add the code generate file
stacks/main.tm.hcl
with the contentRun the generate command only on the 1st stack using the
--tags
optionExpected behavior
I would expect the code generation to be applied only to the 1st stack and not to all. The help page of the
terramate generate
commands indicates that it supports the--tags=TAGS
option to filter stacks by tags.Log Output
The code generation runs for all stacks
Environment (please complete the following information):