spacelift-io/terraform-provider-spacelift

Ability to get Stack Outputs as a Data Source

ikegentz opened this issue · 2 comments

It would be great to have a way to get the outputs from other stacks with a data source.

For example:

data "spacelift_stack_output" "other_stack_output" {
  stack = "some other stack"
  key   = "output key"
}

Right now I'm not aware of a way to do this short of running a null_resource and querying the graphQL API directly.

Spacelift provides a dedicated way to consume outputs of stacks, in the form of references.
Are there use cases that would be better covered by the hypothetical spacelift_stack_output data source?

For us, references would be the reason for wanting the resource.

Consider a scenario where you have a stack that is creating the environment for a service, and you want to make that information available via a context that can attach to any service in the space that will be deploying to that environment.

In order to do this, you have to create an individual reference for every output that you want to connect between those stacks. Later, if you go back and say, add a bunch of additional subnets, then you have to also create more reference connections between those stacks. You can, of course, use foreach and a list(string) in terraform to DRY this up, but you will still need to manually maintain that list of outputs.

If you could get a list of all of the available outputs, then you wouldn't have to do that. You could just iterate on that datasource and create references automatically.