Terraform-provider-azurerm: TF apply/plan have different constraints for "Consumption" tier for API Management

Created on 1 May 2020  路  15Comments  路  Source: terraform-providers/terraform-provider-azurerm

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 (and AzureRM Provider) Version

Terraform v0.12.24

  • provider.azurerm v2.8.0

Affected Resource(s)

  • azurerm_api_management

Issue description

Since 2.8.0 the "Consumption" tier for API Management should be supported. However, I'm unable to set this tier:

Use sku_name = "Consumption"

terraform plan fails with Error: sku_name(Consumption) is not formatted properly.

Use sku_name = "Consumption_0"

terraform plan fails with Error: expected sku_name capacity value to be greater that 1, got 0

Use sku_name = "Consumption_1"

terraform plan passes, however, terraform apply fails with Error: creating/updating API Management Service "<redacted>" (Resource Group "<redacted>"): apimanagement.ServiceClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameters" Message="Invalid parameter: For Consumption SKU Type capacity must be specified as 0."

So it seems that terraform plan requires "Consumption_1" (or greater), but terraform applyrequires "Consumption_0"

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

Debug Output

Here the output when setting sku_name = "Consumption_0" and running terraform apply:

2020-05-01T06:47:23.0441766Z 2020/05/01 06:47:22 [ERROR] module.apim: eval: *terraform.EvalDiff, err: expected sku_name capacity value to be greater that 1, got 0
2020-05-01T06:47:23.0442653Z 2020/05/01 06:47:22 [ERROR] module.apim: eval: *terraform.EvalSequence, err: expected sku_name capacity value to be greater that 1, got 0
2020-05-01T06:47:23.0443329Z 2020/05/01 06:47:22 [TRACE] [walkRefresh] Exiting eval tree: module.apim.azurerm_api_management.customer_api
2020-05-01T06:47:23.0443789Z 2020/05/01 06:47:22 [TRACE] vertex "module.apim.azurerm_api_management.customer_api": visit complete
2020-05-01T06:47:23.0444288Z 2020/05/01 06:47:22 [TRACE] vertex "module.apim.azurerm_api_management.customer_api": dynamic subgraph encountered errors
2020-05-01T06:47:23.0444782Z 2020/05/01 06:47:22 [TRACE] vertex "module.apim.azurerm_api_management.customer_api": visit complete

Expected Behavior

terraform apply and terraform plan should have the same capacity constraints for APIM Consumption tier.

Actual Behavior

terraform plan requires capacity set to 0, whereas terraform apply requires capacity to be set >0.

bug servicapi-management

Most helpful comment

Is there an update and ETA on this please, my client wants to move to consumption plan and there is no way to deploy this currently.

All 15 comments

Looks like there's a bit more to this than just the capacity tier of zero.

Logic to omit some default attributes that the TF provider passes to the Azure API is needed:

Error: creating/updating API Management Service "REDACTED" (Resource Group "REDACTED"): apimanagement.ServiceClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="NotSupported" 
Message="'Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168,Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Ssl30' customProperties are not supported in SkuType Consumption."

Hi @alecor191 , Thanks for opening this issue. This is a bug, and we'll fix it later.

Hi @yupwei68, do you already have an ETA oder milestone for this? There is no possible way to use this feature a.t.m.

Is there an update and ETA on this please, my client wants to move to consumption plan and there is no way to deploy this currently.

@omgapuppy / @yupwei68 from what I can tell, you looked into this (thanks for that!). Do you know if there is any work planned/ongoing to address this?

@omgapuppy / @yupwei68 from what I can tell, you looked into this (thanks for that!). Do you know if there is any work planned/ongoing to address this?

Sorry, I've since stopped looking into it as I didn't have an immediate need or capacity. @yupwei68 looks to have done a significant amount of work around the issue :+1:

@yupwei68 Is the fix released in any version of terraform ? was trying to do some consumption tier deployment of api management, but running into the issues mentioned in this thread.

@cvvarunraj while waiting for this fix, I've deployed my API management via ARM.
Code is in F# but you'll get the gist:

    let stackName = Pulumi.Deployment.Instance.StackName
    // Create an Azure Resource Group
    let resourceGroupName = sprintf "rg-nojaf-apim-%s" stackName
    let resourceGroupArgs = ResourceGroupArgs(Name = input resourceGroupName)
    let resourceGroup = ResourceGroup(resourceGroupName, args = resourceGroupArgs)

    let arm = """
    {
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "resources": [{
            "apiVersion": "2019-12-01",
            "name": "nojaf-apim",
            "type": "Microsoft.ApiManagement/service",
            "location": "westeurope",
            "tags": {},
            "sku": {
                "name": "Consumption",
                "capacity": "0"
            },
            "properties": {
                "publisherEmail": "[email protected]",
                "publisherName": "nojaf"
            }
        }]
    }
    """

    let deployment = TemplateDeployment("nojaf-apim", TemplateDeploymentArgs(ResourceGroupName = io resourceGroup.Name,
                                                                                      TemplateBody = input arm,
                                                                                      DeploymentMode = input "Incremental"))

@here: Is there any update this? We're having to mix Terraform with manual changes.

I see agressive off-topic marking, but not a lot of update info. Has this behavior been confirmed? Is it on the backlogged? do we need more information?

I am also blocked on the same issue running v0.13.5

Hey guys,

is there any news about the given issue? I'm facing this, too on terraform v0.13.5 :(

greetings, Dennis

I'm having the same issue also. Is this likely to be resolved soon?

Bump on 0.13.4

Any news? I'm using terraform v0.14.2 and azure rm 2.41

Was this page helpful?
0 / 5 - 0 ratings