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 multiple revisions for API Management with Terraform #22544

Open
1 task done
sobbbosachi opened this issue Jul 15, 2023 · 1 comment
Open
1 task done

Creating multiple revisions for API Management with Terraform #22544

sobbbosachi opened this issue Jul 15, 2023 · 1 comment

Comments

@sobbbosachi
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 and review the contribution guide to help.

Terraform Version

Terraform 0.13+

AzureRM Provider Version

3.65.0

Affected Resource(s)/Data Source(s)

azurerm_api_management_api

Terraform Configuration Files

resource "azurerm_api_management_api" "createAPIv1r1" {
  name                 = var.api_name
  resource_group_name  = data.azurerm_resource_group.rg.name
  api_management_name  = data.azurerm_api_management.apim.name
  display_name         = var.api_display_name
  path                 = var.api_path
  service_url          = var.api_service_url_v1
  revision             = "1"
  revision_description = "This is the revision 1"
  protocols            = ["https"]
  
  import {
    content_format = var.api_content_format
    content_value  = var.api_specification_v1r1
  }
}


resource "azurerm_api_management_api" "createAPIv1r2" {
  name                = var.api_name
  resource_group_name = data.azurerm_resource_group.rg.name
  api_management_name = data.azurerm_api_management.apim.name
  service_url          = var.api_service_url_v1
  revision             = "2"
  source_api_id        = azurerm_api_management_api.createAPIv1r1.id
  revision_description = "This is the revision 2"

  import {
    content_format = var.api_content_format
    content_value  = var.api_specification_v1r2
  }
}

Debug Output/Panic Output

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 "

Expected Behaviour

The expectation is to have two revisions (1 and 2) in the APIM for this API.

Actual Behaviour

Terraform has been successfully initialized!
azurerm_api_management_api.createAPIv1r1: Creating...
azurerm_api_management_api.createAPIv1r1: Still creating... [10s elapsed]
azurerm_api_management_api.createAPIv1r1: Still creating... [20s elapsed]
azurerm_api_management_api.createAPIv1r1: Still creating... [30s elapsed]
azurerm_api_management_api.createAPIv1r1: Creation complete after 32s [id=/subscriptions/000/resourceGroups/000/providers/Microsoft.ApiManagement/service/000/apis/000]
azurerm_api_management_api.createAPIv1r2: Creating...
azurerm_api_management_api.createAPIv1r2: Still creating... [10s elapsed]
azurerm_api_management_api.createAPIv1r2: Still creating... [20s elapsed]
..........
azurerm_api_management_api.createAPIv1r2: Still creating... [3m30s elapsed]

│ Error: waiting on creating/updating Api: (Name "api_name" / Service Name "000" / Resource Group "000"): 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.createAPIv1r2,
│ on main.tf line AA, in resource "azurerm_api_management_api" "createAPIv1r2":
│ AA: resource "azurerm_api_management_api" "createAPIv1r2" {

Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1

Steps to Reproduce

terraform apply

Important Factoids

No response

References

Related issue:
#22380
#18093
#19069
Mentioned related issues at least used one of the below properties. Therefore, the similar error occurred (e.g. "Can't change property one of the below properties name for non-current revision will be displayed")

References: Revisions in Azure API Management (https://learn.microsoft.com/en-us/azure/api-management/api-management-revisions), in this page the section "Revision descriptions" clearly says that in the "Name" should not be provided.
From the page:

Caution
If you are editing a non-current revision of an API, you cannot change the following properties:
Name
Type
Description
Subscription required
API version
API version description
Path
Protocols

These properties can only be changed in the current revision. If your edits change any of the above properties of a non-current revision, the error message Can't change property for non-current revision will be displayed."

While the terraform plan runs that tried to provide the name information. Which is most likely the error caused (Message="Can't change property Name for non-current revision "). See image below:

image

The solution should/could be to create another resource like azurerm_api_management_api_revision, where the the name argument should not be require. As well as all of the above shouldn't be also part of required argument.

Hence, resource azurerm_api_management_api_revision could be based on the argument source_api_id and required, not on the name (required).

References: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/api_management_api for the arguments name (required).

@celsocoutinho-tangany
Copy link

Is this a duplicate of #12720?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants