Skip to content

The sharing_backend block ​

Use the sharing_backend block to configure a backend that enables outputs sharing between stacks. The sharing_backend block binds input and output blocks and defines how stack outputs are collected and distributed.

INFO

Outputs Sharing is an experimental feature. To use this block, enable the experiment in your Terramate configuration:

hcl
terramate {
  config {
    experiments = ["outputs-sharing"]
  }
}

Arguments ​

  • label (required) - A name for this sharing backend, referenced by input and output blocks.

  • type (required, keyword) - The type of backend. Currently only terraform is supported (also works with OpenTofu).

  • filename (required, string) - The filename used to generate the input and output code (e.g., Terraform variable and output blocks).

  • command (required, list of strings) - The command invoked to extract stack outputs. The command output must be a JSON object.

Syntax ​

hcl
sharing_backend "default" {
  type     = terraform
  filename = "sharing_generated.tf"
  command  = ["terraform", "output", "-json"]
}

Examples ​

Share outputs between Terraform stacks ​

hcl
sharing_backend "default" {
  type     = terraform
  filename = "sharing_generated.tf"
  command  = ["terraform", "output", "-json"]
}

Share outputs between OpenTofu stacks ​

hcl
sharing_backend "tofu" {
  type     = terraform
  filename = "sharing_generated.tf"
  command  = ["tofu", "output", "-json"]
}

See also ​