Skip to content

azurerm_postgresql_flexible_server SKU name validation mismatch between Terraform provider and Azure API #21522

Open
@mathiasbecher

Description

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.3.7

AzureRM Provider Version

3.53.0

Affected Resource(s)/Data Source(s)

azurerm_postgresql_flexible_server

Terraform Configuration Files

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "3.53.0"
    }
  }
}

provider "azurerm" {
  features { }
}

resource "azurerm_resource_group" "this" {
  name     = "rg-postgresql-flexible-server"
  location = "westeurope"
}

resource "azurerm_virtual_network" "this" {
  name                = "vnet-postgresql-flexible-server"
  location            = azurerm_resource_group.this.location
  resource_group_name = azurerm_resource_group.this.name
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "postgresql" {
  name                 = "snet-postgresql-flexible-server"
  virtual_network_name = azurerm_virtual_network.this.name
  resource_group_name  = azurerm_resource_group.this.name
  address_prefixes     = ["10.0.0.0/24"]

  delegation {
    name = "postgresql-flexible-server"

    service_delegation {
      name    = "Microsoft.DBforPostgreSQL/flexibleServers"
      actions = ["Microsoft.Network/virtualNetworks/subnets/join/action"]
    }
  }
}

resource "azurerm_private_dns_zone" "example" {
  name                = "example.postgres.database.azure.com"
  resource_group_name = azurerm_resource_group.this.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "example" {
  name                  = "link-postgresql-flexible-server"
  private_dns_zone_name = azurerm_private_dns_zone.example.name
  virtual_network_id    = azurerm_virtual_network.this.id
  resource_group_name   = azurerm_resource_group.this.name
}

resource "azurerm_postgresql_flexible_server" "example" {
  name                   = "psql-flexible-server"
  resource_group_name    = azurerm_resource_group.this.name
  location               = azurerm_resource_group.this.location
  version                = "13"
  delegated_subnet_id    = azurerm_subnet.postgresql.id
  private_dns_zone_id    = azurerm_private_dns_zone.example.id
  administrator_login    = "psqladmin"
  administrator_password = "P4ssw0rD!!?"
  storage_mb             = 32768
  sku_name               = "B_Standard_B2ms"
  depends_on = [
    azurerm_private_dns_zone_virtual_network_link.example
  ]
}

Debug Output/Panic Output

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_postgresql_flexible_server.example will be created
  + resource "azurerm_postgresql_flexible_server" "example" {
      + administrator_login           = "psqladmin"
      + administrator_password        = (sensitive value)
      + backup_retention_days         = (known after apply)
      + delegated_subnet_id           = (known after apply)
      + fqdn                          = (known after apply)
      + geo_redundant_backup_enabled  = false
      + id                            = (known after apply)
      + location                      = "westeurope"
      + name                          = "psql-flexible-server"
      + private_dns_zone_id           = (known after apply)
      + public_network_access_enabled = (known after apply)
      + resource_group_name           = "rg-postgresql-flexible-server"
      + sku_name                      = "B_Standard_B2ms"
      + storage_mb                    = 32768
      + version                       = "13"
    }

  # azurerm_private_dns_zone.example will be created
  + resource "azurerm_private_dns_zone" "example" {
      + id                                                    = (known after apply)
      + max_number_of_record_sets                             = (known after apply)
      + max_number_of_virtual_network_links                   = (known after apply)
      + max_number_of_virtual_network_links_with_registration = (known after apply)
      + name                                                  = "example.postgres.database.azure.com"
      + number_of_record_sets                                 = (known after apply)
      + resource_group_name                                   = "rg-postgresql-flexible-server"
    }

  # azurerm_private_dns_zone_virtual_network_link.example will be created
  + resource "azurerm_private_dns_zone_virtual_network_link" "example" {
      + id                    = (known after apply)
      + name                  = "link-postgresql-flexible-server"
      + private_dns_zone_name = "example.postgres.database.azure.com"
      + registration_enabled  = false
      + resource_group_name   = "rg-postgresql-flexible-server"
      + virtual_network_id    = (known after apply)
    }

  # azurerm_resource_group.this will be created
  + resource "azurerm_resource_group" "this" {
      + id       = (known after apply)
      + location = "westeurope"
      + name     = "rg-postgresql-flexible-server"
    }

  # azurerm_subnet.postgresql will be created
  + resource "azurerm_subnet" "postgresql" {
      + address_prefixes                               = [
          + "10.0.0.0/24",
        ]
      + enforce_private_link_endpoint_network_policies = (known after apply)
      + enforce_private_link_service_network_policies  = (known after apply)
      + id                                             = (known after apply)
      + name                                           = "snet-postgresql-flexible-server"
      + private_endpoint_network_policies_enabled      = (known after apply)
      + private_link_service_network_policies_enabled  = (known after apply)
      + resource_group_name                            = "rg-postgresql-flexible-server"
      + virtual_network_name                           = "vnet-postgresql-flexible-server"

      + delegation {
          + name = "postgresql-flexible-server"

          + service_delegation {
              + actions = [
                  + "Microsoft.Network/virtualNetworks/subnets/join/action",
                ]
              + name    = "Microsoft.DBforPostgreSQL/flexibleServers"
            }
        }
    }

  # azurerm_virtual_network.this will be created
  + resource "azurerm_virtual_network" "this" {
      + address_space       = [
          + "10.0.0.0/16",
        ]
      + dns_servers         = (known after apply)
      + guid                = (known after apply)
      + id                  = (known after apply)
      + location            = "westeurope"
      + name                = "vnet-postgresql-flexible-server"
      + resource_group_name = "rg-postgresql-flexible-server"
      + subnet              = (known after apply)
    }

Plan: 6 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

azurerm_resource_group.this: Creating...
azurerm_resource_group.this: Creation complete after 1s [id=/subscriptions/d365ef22-b111-4223-b075-05081497572c/resourceGroups/rg-postgresql-flexible-server]
azurerm_private_dns_zone.example: Creating...
azurerm_virtual_network.this: Creating...
azurerm_virtual_network.this: Creation complete after 5s [id=/subscriptions/d365ef22-b111-4223-b075-05081497572c/resourceGroups/rg-postgresql-flexible-server/providers/Microsoft.Network/virtualNetworks/vnet-postgresql-flexible-server]
azurerm_subnet.postgresql: Creating...
azurerm_subnet.postgresql: Creation complete after 4s [id=/subscriptions/d365ef22-b111-4223-b075-05081497572c/resourceGroups/rg-postgresql-flexible-server/providers/Microsoft.Network/virtualNetworks/vnet-postgresql-flexible-server/subnets/snet-postgresql-flexible-server]
azurerm_private_dns_zone.example: Still creating... [10s elapsed]
azurerm_private_dns_zone.example: Still creating... [20s elapsed]
azurerm_private_dns_zone.example: Still creating... [30s elapsed]
azurerm_private_dns_zone.example: Creation complete after 34s [id=/subscriptions/d365ef22-b111-4223-b075-05081497572c/resourceGroups/rg-postgresql-flexible-server/providers/Microsoft.Network/privateDnsZones/example.postgres.database.azure.com]
azurerm_private_dns_zone_virtual_network_link.example: Creating...
azurerm_private_dns_zone_virtual_network_link.example: Still creating... [10s elapsed]
azurerm_private_dns_zone_virtual_network_link.example: Still creating... [20s elapsed]
azurerm_private_dns_zone_virtual_network_link.example: Still creating... [30s elapsed]
azurerm_private_dns_zone_virtual_network_link.example: Creation complete after 33s [id=/subscriptions/d365ef22-b111-4223-b075-05081497572c/resourceGroups/rg-postgresql-flexible-server/providers/Microsoft.Network/privateDnsZones/example.postgres.database.azure.com/virtualNetworkLinks/link-postgresql-flexible-server]
azurerm_postgresql_flexible_server.example: Creating...
╷
│ Error: creating Flexible Server (Subscription: "d365ef22-b111-4223-b075-05081497572c"
│ Resource Group Name: "rg-postgresql-flexible-server"
│ Flexible Server Name: "psql-flexible-server"): performing Create: servers.ServersClient#Create: Failure sending request: StatusCode=0 -- Original Error: Code="ParameterOutOfRange" Message="The value of the 'Sku.Name' should be in: [Standard_B1ms, Standard_B1s, Standard_B2s, Standard_B4ms, Standard_B8ms, Standard_D16s_v3, Standard_D2s_v3, Standard_D32s_v3, Standard_D4s_v3, Standard_D64s_v3, Standard_D8s_v3, Standard_E16s_v3, Standard_E2s_v3, Standard_E32s_v3, Standard_E4s_v3, Standard_E64s_v3, Standard_E8s_v3, Standard_M128ms, Standard_M128s, Standard_M64ms, Standard_M64s, Standard_E48s_v3, Standard_D2ds_v4, Standard_D4ds_v4, Standard_D8ds_v4, Standard_D16ds_v4, Standard_D32ds_v4, Standard_D48ds_v4, Standard_D64ds_v4, Standard_E2ds_v4, Standard_E4ds_v4, Standard_E8ds_v4, Standard_E16ds_v4, Standard_E32ds_v4, Standard_E48ds_v4, Standard_E64ds_v4, Standard_D48s_v3, Standard_E20ds_v4, Standard_M8ms, Standard_M16ms, Standard_M32ts, Standard_M32ls, Standard_M32ms, Standard_M64ls, Standard_M64, Standard_M64m, Standard_M128, Standard_M128m, Standard_B12ms, Standard_B16ms, Standard_B20ms, Standard_D2ads_v5, Standard_D4ads_v5, Standard_D8ads_v5, Standard_D16ads_v5, Standard_D32ads_v5, Standard_D48ads_v5, Standard_D64ads_v5, Standard_D96ads_v5, Standard_E2ads_v5, Standard_E4ads_v5, Standard_E16ads_v5, Standard_E20ads_v5, Standard_E32ads_v5, Standard_E48ads_v5, Standard_E64ads_v5, Standard_E96ads_v5, Standard_D2_v5, Standard_D4_v5, Standard_D8_v5, Standard_D16_v5, Standard_D32_v5, Standard_D48_v5, Standard_D64_v5, Standard_D96_v5, Standard_D2ds_v5, Standard_D4ds_v5, Standard_D8ds_v5, Standard_D16ds_v5, Standard_D32ds_v5, Standard_D48ds_v5, Standard_D64ds_v5, Standard_D96ds_v5, Standard_E2ds_v5, Standard_E4ds_v5, Standard_E8ds_v5, Standard_E16ds_v5, Standard_E20ds_v5, Standard_E32ds_v5, Standard_E48ds_v5, Standard_E64ds_v5, Standard_E96ds_v5, Standard_E104ids_v5, Standard_E2bds_v5, Standard_E4bds_v5, Standard_E8bds_v5, Standard_E16bds_v5, Standard_E32bds_v5, Standard_E48bds_v5, Standard_E64bds_v5]. Verify that the specified parameter value is correct."
│
│   with azurerm_postgresql_flexible_server.example,
│   on main.tf line 54, in resource "azurerm_postgresql_flexible_server" "example":
│   54: resource "azurerm_postgresql_flexible_server" "example" {
│
╵

## After switching sku_name to "Standard_B2ms"
╷
│ Error: "sku_name" is not a valid sku name, got Standard_B2ms
│
│   with azurerm_postgresql_flexible_server.example,
│   on main.tf line 64, in resource "azurerm_postgresql_flexible_server" "example":
│   64:   sku_name               = "Standard_B2ms"
│
╵

Expected Behaviour

Either with sku_name set to "B_Standard_B2ms" or "Standard_B2ms" a PostgreSQL Flexible Server should be created.

Actual Behaviour

The different values for sku_name fail at different times in the terraform apply process:

  • B_Standard_B2ms fails in the Azure API call
  • Standard_B2ms fails during template validation

Steps to Reproduce

terraform apply

Important Factoids

No response

References

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions