Share via


az terraform

Note

This reference is part of the terraform extension for the Azure CLI (version 2.61.0 or higher). The extension will automatically install the first time you run an az terraform command. Learn more about extensions.

This command group is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Azure Terraform experience.

Commands

Name Description Type Status
az terraform export-terraform

Exports the Terraform configuration of the specified resource(s).

Extension Preview

az terraform export-terraform

Preview

Command group 'az terraform' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Exports the Terraform configuration of the specified resource(s).

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}]

Examples

Export a resource group targeting to `azurerm` provider

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

Export a list of resources targeting to `azapi` provider

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

Export all virtual networks in the current subscription, together with their child resources (e.g. subnets) targeting `azapi` provider

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

Optional Parameters

The following parameters are optional, but depending on the context, one or more might become required for the command to execute successfully.

--export-query

Export parameter for resources queried by ARG (Azure Resource Graph). Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: ExportParameter Arguments
--export-resource

Export parameter for individual resources. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: ExportParameter Arguments
--export-resource-group

Export parameter for a resource group. Support shorthand-syntax, json-file and yaml-file. Try "??" to show more.

Property Value
Parameter group: ExportParameter Arguments
--full-properties

Whether to output all non-computed properties in the generated Terraform configuration? This probably needs manual modifications to make it valid.

Property Value
Parameter group: ExportParameter Arguments
Default value: True
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--mask-sensitive

Mask sensitive attributes in the Terraform configuration.

Property Value
Parameter group: ExportParameter Arguments
Default value: True
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--no-wait

Do not wait for the long-running operation to finish.

Property Value
Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--target-provider

The target Azure Terraform Provider.

Property Value
Parameter group: ExportParameter Arguments
Default value: azurerm
Accepted values: azapi, azurerm
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

Property Value
Default value: False
--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

Property Value
Default value: False
--output -o

Output format.

Property Value
Default value: json
Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

Property Value
Default value: False