Skip to content
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

creating an APIM revision results in error message Can't change property ApiVersion for non-current revision #18093

Closed
1 task done
jojoismael opened this issue Aug 24, 2022 · 8 comments · Fixed by #23031
Closed
1 task done

Comments

@jojoismael
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

1.2.6

AzureRM Provider Version

2.84, 3.17.0

Affected Resource(s)/Data Source(s)

azurerm_api_management_api

Terraform Configuration Files

resource "azurerm_api_management_api" "apim-api-env-api" {
    name                = "APISample"
    resource_group_name = azurerm_api_management.apim-env-api.resource_group_name
    api_management_name = azurerm_api_management.apim-env-api.name
    display_name        = "APISample"
    description         = "APISample"
    path                = "APISample"
    protocols           = ["https"]
    revision            = "1"
 
    import {
     content_format = "openapi+json"
     content_value  = file("swaggerFiles/suppliers-1.json")
    }


}
  
  
resource "azurerm_api_management_api" "apim-api-env-api2" {
    name                = "APISample"
    resource_group_name = azurerm_api_management.apim-env-api.resource_group_name
    api_management_name = azurerm_api_management.apim-env-api.name
    display_name        = "APISample"
    description         = "APISample"
    path                = "APISample"
    protocols           = ["https"]
    revision            = "2"
 
    import {
     content_format = "openapi+json"
     content_value  = file("swaggerFiles/suppliers-1.json")
    }


       depends_on = [azurerm_api_management_api.apim-api-env-api]


  }

Debug Output/Panic Output

│ Error: waiting on creating/updating API Management API "APISample" (Resource Group "rg-sample-api"): Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=400 -- Original Error: Code="ValidationError" Message="Can't change property Name for non-current revision "
│
│   with azurerm_api_management_api.apim-api-env-api2,
│   on apim-env-api.tf line 94, in resource "azurerm_api_management_api" "apim-api-env-api2":
│   94:   resource "azurerm_api_management_api" "apim-api-env-api2" {
│

Expected Behaviour

APIM API revision to be created in Azure portal, as per previous behaviour

Actual Behaviour

HTTP 400 returned with message: Can't change property Name for non-current revision

Steps to Reproduce

  1. Set environment variables for tracing

TF_LOG="TRACE"
TF_LOG_PROVIDER="TRACE"
TF_LOG_PATH="c:\tmp\terraform.txt"

  1. Two instances of azurerm_api_management_api declared
  • azurerm_api_management_api.apim-api-env-api for the original API
  • azurerm_api_management_api.apim-api-env-api2 for the revision =2
  • Same file used for imported swagger file
  • Run terraform apply --auto-approve
  • original API succeeds
  • Revision = 2 fails with message: Can't change property Name for non-current revision
  • For both azurerm_api_management_api resources, the same swagger file is used
  1. AzureRM v 2.84 and v.3.17.0 returns error 400: Can't change property Name for non-current revision

  2. Next, copy PUT payload from terraform log file and submit via https://docs.microsoft.com/en-us/rest/api/apimanagement/current-ga/apis/create-or-update?tabs=HTTP#code-try-0

  • Original API succeeds
  • Revision API succeeds as well

Important Factoids

No response

References

No response

@jojoismael jojoismael added the bug label Aug 24, 2022
@github-actions github-actions bot removed the bug label Aug 24, 2022
@jojoismael
Copy link
Author

jojoismael commented Aug 24, 2022

Hello , first of all thanks to the entire terraform and the terraform azurerm provider teams for all of your great work and your hard work is truly appreciated by the community at large.

Previously, this was working perfectly fine , eg, revisions were being created successfully using our existing swagger files.

Then, I had to create a separate environment using our existing working terraform code base and then suddenly , we are getting this 400 error from the azurerm provider.

Tested both in azurerm 2.84 and 3.17 with same HTTP 400 results

In contrast, trying the same payload that was acquired from the terraform diagnostic log file in docs.micosoft.com (try button) results in a successful operation for both the base API and its ;rev-2

Please do take note that in both cases for the base API and revision=2, the same swagger file is being imported

Thanks so much for your assistance!

@jojoismael
Copy link
Author

Update:

Modifying the swagger file’s title and description fields under “info” property to be the same as the name, display name, description and path in the terraform file has resulted on a different error on another field

From:

Message="Can't change property Name for non-current revision"

To:

Message="Can't change property ApiVersion for non-current revision"

│ Error: waiting on creating/updating API Management API "SampleApi" (Resource Group "rg-sample-api"): Future#WaitForCompletion: the number of retries has been exceeded: StatusCode=400 -- Original Error: Code="ValidationError" Message="Can't change property ApiVersion for non-current revision "

any thoughts? Thanks!

@jojoismael jojoismael changed the title Cannot create APIM API revision on terraform but succeeds in docs.microsoft.com try button creating an APIM revision results in error message Can't change property ApiVersion for non-current revision Aug 30, 2022
@rubenaster
Copy link

@jojoismael does working with revisions work for you now? I've noticed that with azurerm 3.17.0+ the revision in the state file is always set to "1", even so it's definitely configured with "2" etc.

@levimatheri

This comment was marked as off-topic.

@S1M0NM

This comment was marked as off-topic.

@rcskosir
Copy link
Contributor

Updating PR linking for this issue - PR #22380 has been superseded by #23031.

@celsocoutinho-tangany
Copy link

I am trying to create a new revision an an existing APIM API, and still getting an error on azurerm 3.89.0:

│ Error: creating/updating Api (Subscription: "xxx"
│ Resource Group Name: "xxx"
│ Service Name: "xxx"
│ Api: "my-api-id;rev=my-revision-id"): polling after CreateOrUpdate: executing request: unexpected status 404 with error: ResourceNotFound: Api not found.
│ 
│   with azurerm_api_management_api.apim_api_revision,
│   on main.tf line 14, in resource "azurerm_api_management_api" "apim_api_revision":
│   14: resource "azurerm_api_management_api" "apim_api_revision" {

With the code:

resource "azurerm_api_management_api" "apim_api_revision" {

  name                = data.azurerm_api_management_api.apim_api.name
  resource_group_name = data.azurerm_api_management_api.resource_group_name
  api_management_name = data.azurerm_api_management_api.api_management_name
  revision            = "my-revision"
  display_name        = "my-revision"
  source_api_id       = data.azurerm_api_management_api.apim_api.id

  import {
    content_format = "openapi"
    content_value  = templatefile("${path.root}/openapi.yaml", {})
  }
}

Am I doing something wrong, or is it the case that #23031 didn't solve the issue?

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.