空的 "azurerm_subscription" 数据块究竟如何获取其数据源参数?

How exactly an empty "azurerm_subscription" data balock gets its Data Source Arguments?

在下面的例子中:

https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/examples/app-service/function-azure-RBAC-role-assignment/main.tf

我们有这个代码片段:

第57行,data.azurerm_subscription.primary.id的值从何而来?我问的是第53行的数据块是空的

如果您选中 data source documentation,则不需要任何输入。唯一的可选参数是 subscription_id:

If this argument is omitted, the subscription ID of the current Azure Resource Manager provider is used.

这取决于您 authenticate 使用 Azure 的方式。

如果您使用的是 Azure CLI,它应该解析为您的 Azure CLI 默认订阅(您可以通过 az account show 找到)。