-
Hello, Thanks for making terramate! I'm evaluating to migrate over from terragrunt In essence, it is not clear to me how I can reference the outputs from a stack into another stack. My infrastructure is divided by
In the
however, I'm not sure how to reference the output, any tips? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @fenos, Thanks for you interest in Terramate and for taking the time explaining your issue. Sorry if I misunderstood the question, but if you are asking about getting values from Terraform outputs from another stack this is not supported by Terramate in the moment. At least not natively in a seamless way. Our approach is to use globals as a way to share data accross stacks so you usually don't need the outputs. You can have globals defined on For scenarios where you need something that is only defined at plan/apply time you can define globals that are used to build the resource and then use those same globals and a data source to retrieve whatever you need that only exists after apply. Then for the ordering you can use the orchestration features, guaranteeing that a stack that creates resource X will be applied before the one that uses a data source to load information about that resource. In the absence of a specific data source you can also use the terraform_remote_state data source to get outputs from another stack, while avoiding any duplications on how to reference the remote state using globals. Possibly there are other solutions too, just trying to give you some idea of what is possible, hope it helps 😃. |
Beta Was this translation helpful? Give feedback.
-
@fenos in addition to @katcipis answer: He described the recommended way of sharing results between stacks. You might face the issue that just ordering stacks is not solving all your needs as you need to apply stack-A before stack-B can be even planned. You can use a neat Terraform behavior to get around this. When you add a dependency to a This is working fine for initial deployments but can get more tricky and complex over time. |
Beta Was this translation helpful? Give feedback.
-
why not to use Terra Cloud workspaces for output? |
Beta Was this translation helpful? Give feedback.
Hi @fenos,
Thanks for you interest in Terramate and for taking the time explaining your issue.
Sorry if I misunderstood the question, but if you are asking about getting values from Terraform outputs from another stack this is not supported by Terramate in the moment. At least not natively in a seamless way.
Our approach is to use globals as a way to share data accross stacks so you usually don't need the outputs. You can have globals defined on
dev/global/network
and then import those globals to use in the stacks, instead of loading them from outputs.For scenarios where you need something that is only defined at plan/apply time you can define globals that are used to build the resource …