-
Notifications
You must be signed in to change notification settings - Fork 709
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Postgresql flexible server private endpoint (#1938)
* feat(postgresql_flexible_servers): add private endpoint * feat(postgresql_flexible_server): add example for private endpoint --------- Co-authored-by: Simon Schneider <[email protected]>
- Loading branch information
Showing
5 changed files
with
177 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
examples/postgresql_flexible_server/104-private-endpoint/configuration.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
global_settings = { | ||
default_region = "region1" | ||
regions = { | ||
region1 = "uksouth" | ||
} | ||
} | ||
|
||
resource_groups = { | ||
postgresql_region1 = { | ||
name = "postgresql-region1" | ||
region = "region1" | ||
} | ||
} | ||
|
||
postgresql_flexible_servers = { | ||
primary_region1 = { | ||
name = "primary-region1" | ||
region = "region1" | ||
version = "12" | ||
sku_name = "MO_Standard_E4s_v3" | ||
zone = 1 | ||
storage_mb = 131072 | ||
|
||
resource_group = { | ||
key = "postgresql_region1" | ||
# lz_key = "" # Set the lz_key if the resource group is remote. | ||
} | ||
|
||
# Auto-generated administrator credentials stored in azure keyvault when not set (recommended). | ||
# administrator_username = "postgresqladmin" | ||
# administrator_password = "ComplxP@ssw0rd!" | ||
keyvault = { | ||
key = "postgresql_region1" # (Required) when auto-generated administrator credentials needed. | ||
# lz_key = "" # Set the lz_key if the keyvault is remote. | ||
} | ||
|
||
# [Optional] Firewall Rules | ||
postgresql_firewall_rules = { | ||
postgresql-firewall-rule1 = { | ||
name = "postgresql-firewall-rule1" | ||
start_ip_address = "10.0.1.10" | ||
end_ip_address = "10.0.1.11" | ||
} | ||
postgresql-firewall-rule2 = { | ||
name = "postgresql-firewall-rule2" | ||
start_ip_address = "10.0.2.10" | ||
end_ip_address = "10.0.2.11" | ||
} | ||
} | ||
|
||
# [Optional] Server Configurations | ||
postgresql_configurations = { | ||
backslash_quote = { | ||
name = "backslash_quote" | ||
value = "on" | ||
} | ||
bgwriter_delay = { | ||
name = "bgwriter_delay" | ||
value = "25" | ||
} | ||
} | ||
|
||
|
||
postgresql_databases = { | ||
sampledb1 = { | ||
name = "sampledb1" | ||
} | ||
sampledb2 = { | ||
name = "sampledb2" | ||
passthrough = true | ||
} | ||
} | ||
|
||
private_endpoints = { | ||
pe1 = { | ||
name = "pe1" | ||
vnet_key = "vnet_region1" | ||
subnet_key = "private_endpoints" | ||
resource_group_key = "postgresql_region1" | ||
|
||
private_service_connection = { | ||
name = "pe1" | ||
is_manual_connection = false | ||
subresource_names = ["postgresqlServer"] | ||
} | ||
|
||
private_dns = { | ||
zone_group_name = "postgres" | ||
keys = ["postgres"] | ||
} | ||
} | ||
} | ||
|
||
tags = { | ||
segment = "sales" | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
# Store the postgresql_flexible_server administrator credentials into keyvault if the attribute keyvault{} block is defined. | ||
keyvaults = { | ||
postgresql_region1 = { | ||
name = "akv" | ||
resource_group_key = "postgresql_region1" | ||
sku_name = "standard" | ||
soft_delete_enabled = true | ||
creation_policies = { | ||
logged_in_user = { | ||
secret_permissions = ["Set", "Get", "List", "Delete", "Purge"] | ||
} | ||
} | ||
} | ||
} | ||
|
||
## Networking configuration | ||
vnets = { | ||
vnet_region1 = { | ||
resource_group_key = "postgresql_region1" | ||
region = "region1" | ||
|
||
vnet = { | ||
name = "postgresql" | ||
address_space = ["10.10.0.0/24"] | ||
} | ||
|
||
subnets = { | ||
private_endpoints = { | ||
name = "private-endpoint" | ||
cidr = ["10.10.0.0/25"] | ||
enforce_private_link_endpoint_network_policies = true | ||
} | ||
} | ||
} | ||
} | ||
|
||
private_dns = { | ||
postgres = { | ||
name = "privatelink.postgres.database.azure.com" | ||
resource_group_key = "postgresql_region1" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
modules/databases/postgresql_flexible_server/private_endpoint.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module "private_endpoint" { | ||
source = "../../networking/private_endpoint" | ||
for_each = try(var.private_endpoints, {}) | ||
|
||
resource_id = azurerm_postgresql_flexible_server.postgresql.id | ||
name = each.value.name | ||
location = local.location | ||
resource_group_name = local.resource_group_name | ||
subnet_id = can(each.value.subnet_id) ? each.value.subnet_id : var.vnets[try(each.value.lz_key, var.client_config.landingzone_key)][each.value.vnet_key].subnets[each.value.subnet_key].id | ||
settings = each.value | ||
global_settings = var.global_settings | ||
base_tags = var.base_tags | ||
tags = local.tags | ||
private_dns = var.private_dns | ||
client_config = var.client_config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters