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

azurerm_postgresql_flexible_server example config costs 484 USD/month #25806

Open
1 task done
miceg opened this issue Apr 30, 2024 · 1 comment
Open
1 task done

azurerm_postgresql_flexible_server example config costs 484 USD/month #25806

miceg opened this issue Apr 30, 2024 · 1 comment

Comments

@miceg
Copy link

miceg commented Apr 30, 2024

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

AzureRM Provider Version

3.96.0

Affected Resource(s)/Data Source(s)

azurerm_postgresql_flexible_server

Terraform Configuration Files

# Copied from https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_flexible_server#example-usage
provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "Australia East"  ## Changed from West Europe
}

resource "azurerm_virtual_network" "example" {
  name                = "example-vn"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  address_space       = ["10.0.0.0/16"]
}

resource "azurerm_subnet" "example" {
  name                 = "example-sn"
  resource_group_name  = azurerm_resource_group.example.name
  virtual_network_name = azurerm_virtual_network.example.name
  address_prefixes     = ["10.0.2.0/24"]
  service_endpoints    = ["Microsoft.Storage"]
  delegation {
    name = "fs"
    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.example.name
}

resource "azurerm_private_dns_zone_virtual_network_link" "example" {
  name                  = "exampleVnetZone.com"
  private_dns_zone_name = azurerm_private_dns_zone.example.name
  virtual_network_id    = azurerm_virtual_network.example.id
  resource_group_name   = azurerm_resource_group.example.name
  depends_on            = [azurerm_subnet.example]
}

resource "azurerm_postgresql_flexible_server" "example" {
  name                   = "example-psqlflexibleserver"
  resource_group_name    = azurerm_resource_group.example.name
  location               = azurerm_resource_group.example.location
  version                = "12"
  delegated_subnet_id    = azurerm_subnet.example.id
  private_dns_zone_id    = azurerm_private_dns_zone.example.id
  administrator_login    = "psqladmin"
  administrator_password = "H@Sh1CoR3!"
  zone                   = "1"

  ### This line costs 4.42 USD/month.
  storage_mb   = 32768

  ### This line costs 136.89 USD/month!
  storage_tier = "P30"

  ### This line costs 343.10 USD/month!
  sku_name   = "GP_Standard_D4s_v3"

  depends_on = [azurerm_private_dns_zone_virtual_network_link.example]

}

Debug Output/Panic Output

n/a

Expected Behaviour

As Terraform doesn't show the cost of resources (like the Azure Portal does), an example resource should be optimised for cost, to minimise the risk of bill shock.

By comparison, using storage_tier = "P4" and sku_name = "B_Standard_B1ms" results in a 23 USD/month bill.

Actual Behaviour

The example resource appears to be optimised for performance, resulting in a 484 USD/month PostgreSQL bill.

Steps to Reproduce

  1. Setup a new Azure PostgreSQL Flexible Server based on the example config.
  2. Wait for your next Azure bill.

Important Factoids

running from Australia East

References

https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_flexible_server#example-usage

@miceg
Copy link
Author

miceg commented May 1, 2024

Related to this issue, I think it's worth going over the other example resources in the AzureRM provider to see if there are other high-cost configurations like this one.

As an example, the azurerm_mysql_flexible_server example has a GP_Standard_D2ds_v4, which sounds like it could also be expensive (but less than the PGSQL one), while the azurerm_mysql_flexible_database example allocates a B_Standard_B1s (which is much more reasonable).

Searching the repository for GP_Standard brings up some hits for database services: https://github.com/search?q=repo%3Ahashicorp%2Fterraform-provider-azurerm+GP_Standard+path%3A%2F%5Ewebsite%5C%2Fdocs%5C%2F%2F&type=code

And searching for high-resource compute sizes (with /[DEFHL]\d{1,2}[a-z]*_/) gets a few hits: https://github.com/search?q=repo%3Ahashicorp%2Fterraform-provider-azurerm+path%3A%2F%5Ewebsite%5C%2Fdocs%5C%2F%2F+%2F%5BDEFHL%5D%5Cd%7B1%2C2%7D%5Ba-z%5D*_%2F&type=code

But I have no idea which of those are reasonable or not.

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