terraformpostgresql
This is an old revision of the document!
Terraform with PostgreSQL
Microsoft Azure
Useful Links
[https://learn.microsoft.com/en-us/azure/developer/terraform/get-started-windows-powershell]
[https://learn.microsoft.com/en-us/azure/developer/terraform/authenticate-to-azure-with-microsoft-account]
[https://learn.microsoft.com/en-us/azure/developer/terraform/deploy-postgresql-flexible-server-database?tabs=azure-cli]
[https://github.com/Azure/terraform/tree/master/quickstart/201-postgresql-fs-db]
[https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_flexible_server]
providers.tf
terraform { required_version = ">=1.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~>3.0" } random = { source = "hashicorp/random" version = ">= 3.4.0" } } } provider "azurerm" { features {} }
variables.tf
variable "resource_group" { default = "DoobDude-WebServer_group" description = "Default Resource Group." } variable "virtual_network" { default = "DoobDude-WebServer-vnet" description = "Default Virtual Network." } variable "nsg" { default = "DoobDude-WebServer-nsg" description = "Default Network Security Group." } variable "location" { default = "UK South" description = "Location of the resource." }
main.tf
Uses existing resource group, virtual network and network security group
resource "random_password" "pass" { length = 20 } resource "azurerm_postgresql_flexible_server" "default" { name = "doob-tf-pg" resource_group_name = var.resource_group location = var.location version = "16" public_network_access_enabled = true administrator_login = "adminTerraform" administrator_password = random_password.pass.result zone = "1" storage_mb = 32768 storage_tier = "P4" sku_name = "B_Standard_B1ms" backup_retention_days = 7 }
terraformpostgresql.1732832715.txt.gz · Last modified: 2025/03/08 22:23 (external edit)