-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nutanix_subnets_v2 multiple filters fail #749
Comments
Found a workaround so Terraform deals with the filter instead of the API or Provider. data "nutanix_subnets_v2" "subnets" {
filter = "name eq '${var.subnet}'"
}
locals {
filtered_data = [
for subnet in data.nutanix_subnets_v2.subnets.subnets : subnet
if subnet["cluster_reference"] == var.cluster
]
ext_id = length(local.filtered_data) > 0 ? local.filtered_data[0]["ext_id"] : null
}` |
Hi @tomrijnland , Correct filter is Please refer https://developers.nutanix.com/api-reference?namespace=networking&version=v4.0#tag/Subnets/operation/listSubnets Query parameters sections for more attributes |
Attribute names are in camel case and supported filter attributes are below as per doc:
|
@GullapalliAkhil @Haroon-Dweikat-Ntx Can we add some guide in docs for filters ? |
Im not sure if Terrafrom is the right place to directly make api calls like that. Now every time you have to look up the api calls reference. It feels very out of Terraform standards to work this way. |
I will note that down. We should have filters allowed attributes noted in provider docs. Will get that added 👍 |
Hi @xerxist We will incorporate the allowed filter attributes into the provider documentation to clarify their usage. Thank you for bringing this to our attention! |
Nutanix Cluster Information
AOS 6.10.0.5
Prism Central 2024.3
Terraform Version
Terraform version v1.10.5
Affected Resource(s)
Terraform Configuration Files
This filter works
This filter with multiple attributes fails.
Debug Output
│ Error: error while fetching subnets : {"data":{"error":[{"$reserved":{"$fv":"v4.r0"},"$objectType":"networking.v4.error.AppMessage","message":"Failed to list subnets due to a bad request - Odata Error: Error while parsing URI","severity":"ERROR","code":"NETWORKING-10002","locale":"en_US"}],"$reserved":{"$fv":"v4.r0"},"$objectType":"networking.v4.error.ErrorResponse"},"$reserved":{"$fv":"v4.r0"},"$objectType":"networking.v4.config.GetSubnetApiResponse","metadata":{"flags":[{"$reserved":{"$fv":"v1.r0"},"$objectType":"common.v1.config.Flag","name":"hasError","value":true},{"$reserved":{"$fv":"v1.r0"},"$objectType":"common.v1.config.Flag","name":"isPaginated","value":false},{"$reserved":{"$fv":"v1.r0"},"$objectType":"common.v1.config.Flag","name":"isTruncated","value":false}],"$reserved":{"$fv":"v1.r0"},"$objectType":"common.v1.response.ApiResponseMetadata","links":[{"$reserved":{"$fv":"v1.r0"},"$objectType":"common.v1.response.ApiLink","href":"https://x.x.x.x:9440/api/networking/v4.0/config/subnets","rel":"self"}],"totalAvailableResults":0}}
Panic Output
Expected Behavior
Should find the subnet for the given cluster.
Actual Behavior
Above error
Steps to Reproduce
terraform apply
The text was updated successfully, but these errors were encountered: