Proposal: attribute for fetching outputs
Currently the @output attribute can be used to declare configuration outputs (in TB master).
To retrieve such outputs an io.#Outputs task is provided. The task can fetch the outputs from some env/config.
The usage is to define it as a pre_task and reference the needed outputs in inputs values of the configuration:
configurations: otherConfig: {
// We output a static value, but in the real world this would be a dynamic
// value
some_output: "bar" @output()
}
configurations: myConfig: {
// Gets outputs from otherConfig
run: pre_tasks: io.#Outputs & {
env: "my-env"
config: "otherConfig"
outputs: some_output: string
}
tfvars: {
// Use output from otherConfig in inputs
foo: run.pre_tasks.outputs.some_output
}
}
As we can see the io.#Outputs is able to fetch outputs from any env / config.
However, the most common use case for a configuration is to use outputs from previous configurations on the same env.
For this we can imagine a more simple way using another attribute. This could look like this:
configurations: myConfig: {
tfvars: {
foo: string @use(config=otherConfig,output_name=bar)
}
}
The obvious advantage is that the config looks more straightforward as there is no indirection. Less typing for the config writer also.
As attribute contents (key/values) cannot be dynamic, the current env is always used and cannot be changed.
For use-cases where a configuration needs outputs from other envs the io.#Outputs needs to be used. The only use-case I can think of is fe_whitelist which needs to allow IPs from child or parent zones.
Maybe this use-case should be treated differently and not rely on TB outputs ?