az terraform

注释

此参考是 Azure CLI 的 terraform 扩展(版本 2.61.0 或更高版本)的一部分。 该扩展将在首次运行 az terraform 命令时自动安装。 了解更多关于扩展 的相关信息。

此命令组处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus

Azure Terraform 体验。

命令

名称 说明 类型 Status
az terraform export-terraform

导出指定资源的 Terraform 配置。

扩展 预览

az terraform export-terraform

预览

命令组“az terraform”处于预览状态,正在开发中。 参考和支持级别:https://aka.ms/CLI_refstatus

导出指定资源的 Terraform 配置。

az terraform export-terraform [--export-query]
                              [--export-resource]
                              [--export-resource-group]
                              [--full-properties {0, 1, f, false, n, no, t, true, y, yes}]
                              [--mask-sensitive {0, 1, f, false, n, no, t, true, y, yes}]
                              [--no-wait {0, 1, f, false, n, no, t, true, y, yes}]
                              [--target-provider {azapi, azurerm}]

示例

将目标为“azurerm”提供程序的资源组导出

az terraform export-terraform --export-resource-group '{resource-group-name:my-rg}'

将目标为“azapi”提供程序的资源列表

az terraform export-terraform --full-properties false --target-provider azapi --export-resource '{resource-ids:[id1,id2,id3]}'

导出当前订阅中的所有虚拟网络及其子资源(例如子网)以“azapi”提供程序为目标

az terraform export-terraform --full-properties false --target-provider azapi --export-query "{query:'type =~ \"microsoft.network/virtualnetworks\"',recursive:true}"

可选参数

--export-query

ARG(Azure Resource Graph)查询的资源的导出参数。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

--export-resource

导出单个资源的参数。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

--export-resource-group

导出资源组的参数。 支持速记语法、json-file 和 yaml-file。 请尝试“??” 以显示更多内容。

--full-properties

是否输出生成的 Terraform 配置中的所有非计算属性? 这可能需要手动修改才能使其有效。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
默认值: True
--mask-sensitive

在 Terraform 配置中屏蔽敏感属性。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
默认值: True
--no-wait

不等待长时间运行的操作完成。

接受的值: 0, 1, f, false, n, no, t, true, y, yes
--target-provider

目标 Azure Terraform 提供程序。

接受的值: azapi, azurerm
默认值: azurerm
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 使用 --debug 获取完整的调试日志。