Closed weineran closed 4 days ago
Hi @weineran ,
Thank you for taking time to open this issue!
The staticIp
field is a read-only field that only could be accessed by the output
. Here's an example:
resource "azapi_resource" "container_app_environment" {
type = "Microsoft.App/managedEnvironments@2024-03-01"
name = "managedEnvironment-example"
location = "eastus"
parent_id = azurerm_resource_group.resource_group.id
body = {...}
response_export_values = ["*"] // it means export everything
}
output "staticIp" {
value = azapi_resource. container_app_environment.output.properties.staticIp
}
More details: https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/azapi_resource#response_export_values https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/azapi_resource#output
Thanks @ms-henglu but when I try that, and run terraform plan
, I get this error:
╷
│ Error: Unsupported attribute
│
│ on \path\to\apps.tf line 195, in output "staticIp":
│ 195: value = azapi_resource.container_app_environment.output.properties.staticIp
│ ├────────────────
│ │ azapi_resource.container_app_environment.output is object with no attributes
│
│ This object does not have an attribute named "properties".
╵
Please check whether response_export_values = ["*"]
is specified in the config.
Please check whether response_export_values = ["*"] is specified in the config. Confirmed, yes it is.
when I try that, and run terraform plan, I get this error: I mispoke. It was the
terraform import
command that gave this error.
I commented out the output
block, completed the terraform import
, then ran the terraform plan
and it seems to have worked!
Changes to Outputs:
+ staticIp = (known after apply)
Thank you 🙏
Reference: https://learn.microsoft.com/en-us/azure/templates/microsoft.app/managedenvironments?pivots=deployment-language-terraform
Bug Description: After creating a managed container apps environment using
azapi_resource
of typeMicrosoft.App/managedEnvironments@2024-03-01
, thestaticIp
field is not exposed / accessible to other resources.Steps to reproduce
Build a managed container apps environment and try to reference the static IP address in a different resource. Like this:
output "container_app_environment_ip" { value = azapi_resource.container_app_environment.body.properties.staticIp }
╷ │ Error: Unsupported attribute │ │ on apps.tf line 183, in output "container_app_environment_ip": │ 183: value = azapi_resource.container_app_environment.body.properties.staticIp │ ├──────────────── │ │ azapi_resource.container_app_environment.body.properties is object with 9 attributes │ │ This object does not have an attribute named "staticIp". ╵
{ ... "type": "Microsoft.App/managedEnvironments", "location": "East US", ... "properties": { "provisioningState": "Succeeded", ... "staticIp": "10.0.4.220", } }
╷ │ Error: Invalid configuration │ │ with azapi_resource.container_app_environment, │ on apps.tf line 137, in resource "azapi_resource" "container_app_environment": │ 137: resource "azapi_resource" "container_app_environment" { │ │ embedded schema validation failed: the argument "body" is invalid: │
properties.staticIp
is not expected here, it's read only │ You can try to updateazapi
provider to the latest version or disable the validation using the feature flagschema_validation_enabled = false
within the resource block ╵