Terraform output value used as a variable in .tf

Hi,
I’m trying to retrieve the azure subscription_id and repurpose as a variable to create an azure service principal.

Is it possible to variable an output?

Something like this -

data “azurerm_subscriptions” “available” {
}

output “subscription_id” {
value = “${data.azurerm_subscriptions.available.subscriptions[0].subscription_id}”
}

Thank you,
Carl

You can make anything an output as long and the value is valid. That includes a data resource.

One minor thing to keep in mind, that entire module (guessing you’re making a module with an output) would be in the TF graph of whatever uses that output.