### Default Firewall Rule Example Source: https://github.com/azure/terraform-azurerm-avm-res-dbforpostgresql-flexibleserver/blob/main/README.md An example of a default firewall rule configuration that allows all IP addresses. ```json { "rule1": { "end_ip_address": "255.255.255.255", "name": "AllowAllFireWallRule", "start_ip_address": "0.0.0.0" } } ``` -------------------------------- ### Configure Firewall Rules for PostgreSQL Flexible Server Source: https://github.com/azure/terraform-azurerm-avm-res-dbforpostgresql-flexibleserver/blob/main/README.md Define a map of firewall rules for the PostgreSQL Flexible Server. Each rule requires a name and start/end IP addresses to specify the allowed network access. ```hcl map(object({ name = string end_ip_address = string start_ip_address = string })) ``` -------------------------------- ### Configure Diagnostic Settings for PostgreSQL Flexible Server Source: https://github.com/azure/terraform-azurerm-avm-res-dbforpostgresql-flexibleserver/blob/main/README.md Define a map of diagnostic settings to be created on the PostgreSQL Flexible Server. This includes specifying log and metric categories, destination types, and resource IDs for storage or event hubs. ```hcl map(object({ name = optional(string, null) log_categories = optional(set(string), []) log_groups = optional(set(string), ["allLogs"]) metric_categories = optional(set(string), ["AllMetrics"]) log_analytics_destination_type = optional(string, "Dedicated") workspace_resource_id = optional(string, null) storage_account_resource_id = optional(string, null) event_hub_authorization_rule_resource_id = optional(string, null) event_hub_name = optional(string, null) marketplace_partner_resource_id = optional(string, null) })) ``` -------------------------------- ### Terraform Configuration for PostgreSQL Flexible Server Source: https://github.com/azure/terraform-azurerm-avm-res-dbforpostgresql-flexibleserver/blob/main/examples/default/README.md This is the main Terraform configuration file. It defines required providers, a resource group, and calls the PostgreSQL Flexible Server module with various settings including high availability and SKU. ```hcl terraform { required_version = ">= 1.9, < 2.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 4.12" } random = { source = "hashicorp/random" version = "~> 3.6" } } } provider "azurerm" { features {} } ## Section to provide a random Azure region for the resource group # This allows us to randomize the region for the resource group. module "regions" { source = "Azure/regions/azurerm" version = "0.8.2" } # This allows us to randomize the region for the resource group. resource "random_integer" "region_index" { max = length(module.regions.regions) - 1 min = 0 } ## End of section to provide a random Azure region for the resource group # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.2" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" #module.regions.regions[random_integer.region_index.result].name name = module.naming.resource_group.name_unique } resource "random_password" "myadminpassword" { length = 16 override_special = "_%@" special = true } # This is the module call # Do not specify location here due to the randomization above. # Leaving location as `null` will cause the module to use the resource group location # with a data source. module "test" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.postgresql_server.name_unique resource_group_name = azurerm_resource_group.this.name administrator_login = "psqladmin" administrator_password = random_password.myadminpassword.result enable_telemetry = var.enable_telemetry geo_redundant_backup_enabled = true high_availability = { mode = "ZoneRedundant" standby_availability_zone = 2 } server_version = 16 sku_name = "GP_Standard_D2s_v3" tags = null zone = 1 } ``` -------------------------------- ### Default High Availability Configuration Source: https://github.com/azure/terraform-azurerm-avm-res-dbforpostgresql-flexibleserver/blob/main/README.md The default high availability configuration for the PostgreSQL Flexible Server, set to 'ZoneRedundant' mode. ```json { "mode": "ZoneRedundant" } ``` -------------------------------- ### Terraform Configuration for PostgreSQL Deployment Source: https://github.com/azure/terraform-azurerm-avm-res-dbforpostgresql-flexibleserver/blob/main/examples/database/README.md This HCL code configures Terraform, providers, and modules to deploy an Azure Database for PostgreSQL flexible server and a database. It includes random resource generation for region and password, and naming conventions for resource uniqueness. ```hcl terraform { required_version = ">= 1.9, < 2.0" required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 4.12" } random = { source = "hashicorp/random" version = "~> 3.6" } } } provider "azurerm" { features {} } ## Section to provide a random Azure region for the resource group # This allows us to randomize the region for the resource group. module "regions" { source = "Azure/regions/azurerm" version = "0.8.2" } # This allows us to randomize the region for the resource group. resource "random_integer" "region_index" { max = length(module.regions.regions) - 1 min = 0 } ## End of section to provide a random Azure region for the resource group # This ensures we have unique CAF compliant names for our resources. module "naming" { source = "Azure/naming/azurerm" version = "0.4.2" } # This is required for resource modules resource "azurerm_resource_group" "this" { location = "australiaeast" # module.regions.regions[random_integer.region_index.result].name name = module.naming.resource_group.name_unique } resource "random_password" "myadminpassword" { length = 16 override_special = "_%@" special = true } # This is the module call # Do not specify location here due to the randomization above. # Leaving location as `null` will cause the module to use the resource group location # with a data source. module "server" { source = "../../" location = azurerm_resource_group.this.location name = module.naming.postgresql_server.name_unique resource_group_name = azurerm_resource_group.this.name administrator_login = "psqladmin" administrator_password = random_password.myadminpassword.result enable_telemetry = var.enable_telemetry geo_redundant_backup_enabled = true high_availability = { mode = "ZoneRedundant" standby_availability_zone = 2 } server_version = 16 sku_name = "GP_Standard_D2s_v3" tags = null zone = 1 } module "database" { source = "../../modules/database" name = module.naming.postgresql_database.name_unique server_id = module.server.resource_id charset = "UTF8" collation = "en_US.utf8" } ``` -------------------------------- ### Configure High Availability for PostgreSQL Flexible Server Source: https://github.com/azure/terraform-azurerm-avm-res-dbforpostgresql-flexibleserver/blob/main/README.md Define the high availability configuration for the PostgreSQL Flexible Server, specifying the mode (e.g., ZoneRedundant) and optionally the standby availability zone. ```hcl object({ mode = string standby_availability_zone = optional(string) }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.