Resolving Terraform Error ApplicationGatewayInvalidPublicIpSku : Application Gateway SKU Mismatch with Public IP

If you’ve stumbled upon the following Terraform error while setting up an Application Gateway with a Public IP, this blog post will guide you through the steps to fix it.

│ Error: creating Application Gateway: (Name "aks-appgateway" / Resource Group "rg-aks-production"): network.ApplicationGatewaysClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="ApplicationGatewayInvalidPublicIpSku" Message="Application gateway /subscriptions/***/resourceGroups/rg-aks-production/providers/Microsoft.Network/applicationGateways/aks-appgateway with SKU Standard_v2 can only reference public ip with Standard SKU." Details=[]


The error is straightforward—it points to a discrepancy in the SKU (Stock Keeping Unit) between the Application Gateway and the associated Public IP. The Application Gateway is set with SKU Standard_v2, but the linked Public IP must also have a Standard SKU. Notably, the initial deployment of azurerm_public_ip lacked a SKU reference.

resource "azurerm_public_ip" "example" {
  name                = "appgateway-pip"
  resource_group_name = var.resource_group_name
  location            = var.location
  allocation_method   = "Static"
}

Referencing the Terraform documentation, the sku attribute is optional, defaulting to “Basic.” Here’s the relevant excerpt:

sku – (Optional) The SKU of the Public IP. Accepted values are Basic and Standard. Defaults to Basic. Changing this forces a new resource to be created.

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip#sku

The fix

To resolve the issue, a simple adjustment is required in your Terraform configuration for azurerm_public_ip. Add the sku attribute and set it to “Standard” as follows:

resource "azurerm_public_ip" "example" {
  name                = "appgateway-pip"
  resource_group_name = var.resource_group_name
  location            = var.location
  allocation_method   = "Static"
  sku                = "Standard"
}

Re-run your Terraform and the error will be resolved. This will apply the changes, and the Application Gateway SKU mismatch error should be resolved.

Leave a Reply