terraform-provider-azapi
terraform-provider-azapi copied to clipboard
`Microsoft.RedHatOpenShift/openShiftClusters@2023-07-01-preview` - switching api-version gets error 400
I have this resource, which I bumped the api from one version to another (https://learn.microsoft.com/en-us/azure/templates/microsoft.redhatopenshift/openshiftclusters?pivots=deployment-language-terraform) - but now I provide an explicit value for a property which was not there before (it was an opt-in feature before, that I had to enable at provider level).
# module.aro.azapi_resource.aro will be updated in-place
~ resource "azapi_resource" "aro" {
id = "/subscriptions/XXX/resourceGroups/ftm-aro-dev-nore-rg/providers/Microsoft.RedHatOpenShift/openShiftClusters/ftm-aro-dev-nore-aro"
name = "ftm-aro-dev-nore-aro"
tags = {
"contactemail" = "XXXX"
"costallocation" = "XXXX"
"environment" = "dev"
}
~ type = "Microsoft.RedHatOpenShift/openShiftClusters@2022-09-04" -> "Microsoft.RedHatOpenShift/openShiftClusters@2023-07-01-preview"
# (9 unchanged attributes hidden)
}
now it fails with:
Error: creating/updating "Resource: (ResourceId \"/subscriptions/XXXX/resourceGroups/ftm-aro-dev-nore-rg/providers/Microsoft.RedHatOpenShift/openShiftClusters/ftm-aro-dev-nore-aro\" / Api Version \"2023-07-01-preview\")": PUT https://management.azure.com/subscriptions/XXXX/resourceGroups/ftm-aro-dev-nore-rg/providers/Microsoft.RedHatOpenShift/openShiftClusters/ftm-aro-dev-nore-aro
│ --------------------------------------------------------------------------------
│ RESPONSE 400: 400 Bad Request
│ ERROR CODE: PropertyChangeNotAllowed
│ --------------------------------------------------------------------------------
│ {
│ "error": {
│ "code": "PropertyChangeNotAllowed",
│ "message": "Changing property 'properties.networkProfile.outboundType' is not allowed.",
│ "target": "properties.networkProfile.outboundType"
│ }
│ }
which is a bit strange - because I set the same value as which is returned with az aro list (the value is UserDefinedRouting).
how can I get out of this?
Hi @davidkarlsen ,
Thank you for taking time to report this issue and apologize for the late response.
It seems to be an issue on the API side. There's a workaround for this, hope it could help you.
- Copy
azapi_resource.aro
block, and name it "import" for example, then change its type toMicrosoft.RedHatOpenShift/openShiftClusters@2023-07-01-preview
- Run
terraform import azapi_resource.import /subscriptions/****/resourceGroups/****/providers/Microsoft.RedHatOpenShift/openShiftClusters/****?api-version=2023-07-01-preview
to import the resource into terraform state - Run
terraform plan
to check the diff. When import a new resource, azapi provider will add every configurable fields in the state, so you'll see there're lots of fields are not defined in the config, you can add the necessary fields to the config then runterraform apply
to update the terraform state. - Run
terraform state rm azapi_resource.aro
command to remove the old resource from terraform state. And remove theazapi_resource.aro
block from config.