2
votes

I am trying to build a Key Vault resource and associate to my service principal in azure. I am working through the required fields and I need to provide my Azure AD Tenant id where my service principal is registered. Is there an easy way to access this in a terraform file? Rather not use ENV vars.

1

1 Answers

5
votes

Figured it out. Terraform has an option to generate a data object.

https://www.terraform.io/docs/providers/azurerm/d/client_config.html

main.tf file

data "azurerm_client_config" "current" {}

usage

tenant_id = "${data.azurerm_client_config.current.tenant_id}"