terraform-provider-azurerm: Unable to create azurerm_api_management_api with imported content file with azurerm > 3.69.0
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
1.5.7
AzureRM Provider Version
3.69.0
Affected Resource(s)/Data Source(s)
azurerm_api_management_api
Terraform Configuration Files
data "azurerm_api_management" "apim" {
name = var.apim_name
resource_group_name = var.resource_group_name
}
resource "azurerm_api_management_api" "api" {
for_each = var.managed_apis
name = var.instance_id != null ? "${each.key}-${var.instance_id}" : each.key
display_name = "${each.value.display_name} [${upper(var.env)}]"
resource_group_name = data.azurerm_api_management.apim.resource_group_name
api_management_name = data.azurerm_api_management.apim.name
revision = "current"
soap_pass_through = each.value.import_type == "wsdl" ? true : false
path = local.is_shared_service ? "${local.app_context}/${each.value.service_path}" : each.value.service_path
protocols = ["https"]
subscription_required = each.value.subscription_required
version = each.value.version != null ? each.value.version : null
version_set_id = each.value.version_set != null ? azurerm_api_management_api_version_set.version_set[each.value.version_set].id : null
dynamic "import" {
for_each = each.value.api_file == null ? [] : [1]
content {
content_format = each.value.import_type
content_value = file("${var.paths.apis}/${each.value.api_file}")
dynamic "wsdl_selector" {
for_each = each.value.wsdl_selector
content {
service_name = wsdl_selector.value.service_name
endpoint_name = wsdl_selector.value.endpoint_name
}
}
}
}
depends_on = [azurerm_api_management_api_version_set.version_set]
}
EXAMPLE managed_apis var:
managed_apis = {
"testapi" = {
display_name = "test"
service_path = "test"
import_type = "openapi"
// This product id will have to match one of the the product id's in the
// Azure Portal in the APIs -> Products section of the APIM. If you don't
// see one that matches the project your API is for then reach out your
// team lead (if not using a shared services apim) or the Cloud Services
// team in MS Teams (if using share services apim)
product_id = "test"
api_file = "test.openapi.yaml"
subscription_required = false
wsdl_selector = []
},
}
EXAMPLE test.openapi.yaml
openapi: 3.0.0
info:
title: title
description: endpoint
version: 1.0.0
servers:
- url: "https://redacted.com/test/v1/test/test"
description: environment
paths:
/default:
post:
operationId: default
summary: Default
description: Default operation
responses:
"200":
description: Accepted
content:
application/json:
schema:
$ref: "#/components/schemas/response"
components:
schemas:
response:
type: object
properties:
status:
type: string
example: success
securitySchemes:
basicAuth:
type: http
scheme: basic
Debug Output/Panic Output
terraform [init -upgrade=false]
Running command terraform with args [init -upgrade=false]
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/azurerm versions matching "< 4.0.0"...
- Installing hashicorp/azurerm v3.73.0...
- Installed hashicorp/azurerm v3.73.0 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
terraform [apply -input=false -auto-approve -var managed_apis={"test-api-v1" = {"display_name" = "Test API", "service_path" = "test/test", "subscription_required" = false, "wsdl_selector" = [], "product_id" = "test", "api_file" = "test.openapi.yaml", "import_type" = "openapi", "version" = null, "version_set" = null}} -var project_context=testing -var version_sets=[] -var instance_id=256 -var env=dev -var api_operations=[] -var apim_product={} -var api_policies=[] -var operation_policies=[] -var named_values={} -var resource_group_name=rg-redacted-01 -var apim_name=apim-redacted-01 -var paths={"apis" = "/home/runner/work/terraform-azure-managed-api-module/terraform-azure-managed-api-module/test/apis", "policies" = null} -no-color -lock=false]
Running command terraform with args [apply -input=false -auto-approve -var managed_apis={"test-api-v1" = {"display_name" = "Test API", "service_path" = "test/test", "subscription_required" = false, "wsdl_selector" = [], "product_id" = "test", "api_file" = "test.openapi.yaml", "import_type" = "openapi", "version" = null, "version_set" = null}} -var project_context=testing -var version_sets=[] -var instance_id=256 -var env=dev -var api_operations=[] -var apim_product={} -var api_policies=[] -var operation_policies=[] -var named_values={} -var resource_group_name=rg-redacted-01 -var apim_name=apim-redacted-01 -var paths={"apis" = "/home/runner/work/terraform-azure-managed-api-module/terraform-azure-managed-api-module/test/apis", "policies" = null} -no-color -lock=false]
data.azurerm_api_management.apim: Reading...
data.azurerm_api_management.apim: Read complete after 1s [id=/subscriptions/***/resourceGroups/rg-redacted-01/providers/Microsoft.ApiManagement/service/apim-redacted-01]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# azurerm_api_management_api.api["test-api-v1"] will be created
+ resource "azurerm_api_management_api" "api" {
+ api_management_name = "apim-redacted-01"
+ api_type = (known after apply)
+ display_name = "Test API [DEV]"
+ id = (known after apply)
+ is_current = (known after apply)
+ is_online = (known after apply)
+ name = "test-api"
+ path = "test/test"
+ protocols = [
+ "https",
]
+ resource_group_name = "rg-redacted-01"
+ revision = "current"
+ service_url = (known after apply)
+ soap_pass_through = false
+ subscription_required = false
+ version = (known after apply)
+ version_set_id = (known after apply)
+ import {
+ content_format = "openapi"
+ content_value = <<-EOT
openapi: 3.0.0
info:
title: title
description: endpoint
version: 1.0.0
servers:
- url: "https://redacted.com/test/v1/test/test"
description: sandbox environment
paths:
/default:
post:
operationId: default
summary: Default
description: Default operation
responses:
"200":
description: Accepted
content:
application/json:
schema:
$ref: "#/components/schemas/response"
components:
schemas:
response:
type: object
properties:
status:
type: string
example: success
securitySchemes:
basicAuth:
type: http
scheme: basic
EOT
}
}
# azurerm_api_management_product_api.product_api["test-api-v1"] will be created
+ resource "azurerm_api_management_product_api" "product_api" {
+ api_management_name = "apim-redacted-01"
+ api_name = "test-api"
+ id = (known after apply)
+ product_id = "test"
+ resource_group_name = "rg-redacted-01"
}
Plan: 2 to add, 0 to change, 0 to destroy.
azurerm_api_management_api.api["test-api-v1"]: Creating...
azurerm_api_management_api.api["test-api-v1"]: Still creating... [10s elapsed]
Warning: Argument is deprecated
with azurerm_api_management_api.api["test-api-v1"],
on main.tf line 14, in resource "azurerm_api_management_api" "api":
14: soap_pass_through = each.value.import_type == "wsdl" ? true : false
`soap_pass_through` will be removed in favour of the property `api_type` in
version 4.0 of the AzureRM Provider
(and one more similar warning elsewhere)
Error: creating/updating Api (Subscription: "***"
Resource Group Name: "rg-redacted-01"
Service Name: "apim-redacted-01"
Api: "test-api"): polling after CreateOrUpdate: executing request: unexpected status 404 with error: ResourceNotFound: Api not found.
with azurerm_api_management_api.api["test-api-v1"],
on main.tf line 6, in resource "azurerm_api_management_api" "api":
Expected Behaviour
The azurerm_api_management_api should be created successfully.
I’m trying to create an azurerm_api_management_api using an openapi type imported file.
Actual Behaviour
With any version > 3.69.0, The azurerm_api_management_api creation fails with the following error:
Error: creating/updating Api (Subscription: "***"
Resource Group Name: "rg-redacted-01"
Service Name: "apim-dedacted-01"
Api: "test-api"): polling after CreateOrUpdate: executing request: unexpected status 404 with error: ResourceNotFound: Api not found.
If you used <= 3.69.0 the creation is successful.
Steps to Reproduce
terraform apply
Important Factoids
No response
References
No response
About this issue
- Original URL
- State: open
- Created 9 months ago
- Reactions: 16
- Comments: 22