Closed jchancellor-ms closed 1 month ago
Hi @jchancellor-ms ,
Thank you for taking time to report this issue.
The terraform doesn't support reading the configuration when import a resource. So the azapi_resource
couldn't know the response_export_values
and set the output
. We're working on improving the default behavior for the output
field in the next major release.
Here're some workarounds for this case:
Recommended: Use azapi_resource.this_private_cloud.identity
, the identity
block will be set during import.
Add response_export_values = ["identity"]
in the config, and apply it. Then you could use the values in the output
field.
@ms-henglu - I was able to use option 1 to bypass the identity challenge, but I'm also getting This object does not have an attribute named "properties"
as an error. I tried explicitly setting the response_export_values
to ["properties"] but that did not correct the error. Is there a way to suppress import errors on the properties block until the next major release?
Hi @jchancellor-ms
Is there a way to suppress import errors on the properties block until the next major release?
Yes, you could use the try
function to provide a default value if error happens.
More details: https://developer.hashicorp.com/terraform/language/functions/try
I'll close this issue as it's completed, but feel free to reopen it if there's any question
I've created an AVS AVM module using AzAPI. Because installs of AVS can take 4-6 hours, it is not uncommon for the install to drop a connection requiring a Terraform import to re-initiate the installation of the rest of the module. Using version 1.13.1 with the HCL features enabled, I get the following errors when running terraform import.
However, if I create a data azapi resource using the same configuration then the output works fine and shows the identity element.
I suspect this is a bug in how terraform import interacts with AzAPI outputs in the latest version.
Full example of the code can be found here - https://github.com/Azure/terraform-azurerm-avm-res-avs-privatecloud/blob/main/examples/full/main.tf