Created VNet and two subnets first and pass the values as variables to terraform.
az group create -n TestingTFCLI -l CentralUS
az network vnet create -g TestingTFCLI -n myVNET --address-prefixes 10.0.0.0/8
az network nsg create -g TestingTFCLI -n MyNsg --tags super_secure no_80 no_22
az network vnet subnet create -n mySubNet -g TestingTFCLI --vnet-name myVNET --address-prefixes 10.240.0.0/16 --network-security-group MyNsg
az network vnet subnet create -n mySubNet1 -g TestingTFCLI --vnet-name myVNET --address-prefixes 10.230.0.0/16 --network-security-group MyNsg
az network vnet subnet update --resource-group TestingTFCLI --name mySubNet1 --vnet-name myVNET --delegations Microsoft.DBforPostgreSQL/flexibleServers
I tried creating azure postgres with below template, but getting error as InternalServerError code.
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-resources"
location = "Central US"
}
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 = var.virtual_network_id
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_postgresql_flexible_server" "example" {
name = "example-psqlflexibleserver2022-1"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
version = "13"
delegated_subnet_id = var.subnet_id
private_dns_zone_id = azurerm_private_dns_zone.example.id
administrator_login = var.username
administrator_password = var.password
zone = "1"
storage_mb = 131072
sku_name = "GP_Standard_D2s_v3"
depends_on = [azurerm_private_dns_zone_virtual_network_link.example]
}
error:
│ Error: waiting for creation of the Postgresql Flexible Server "example-psqlflexibleserver2022-1" (Resource Group "example-resources"): Future#WaitForCompletion: context has been cancelled: StatusCode=200 -- Original Error: context deadline exceeded
│
│ with azurerm_postgresql_flexible_server.example,
│ on main.tf line 22, in resource "azurerm_postgresql_flexible_server" "example":
│ 22: resource "azurerm_postgresql_flexible_server" "example" {