PostgreSQL Flexible Server module can deploy these resources:
- azurerm_postgresql_flexible_server (required)
- azurerm_postgresql_flexible_server_database (optional)
- azurerm_postgresql_flexible_server_configuration (optional)
- azurerm_postgresql_flexible_server_active_directory_administrator (optional)
- azurerm_monitor_diagnostic_setting (optional)
- azurerm_private_endpoint (optional)
Example variables structure is located in variables.md.
Example use case is located in test-case/locals.tf.
You can also see changelog.
Terraform documentation:
https://registry.terraform.io/providers/hashicorp/azurerm/4.1.0/docs/resources/private_endpoint
WARNING: AzureRM provider had been updated to a new major version. Many breaking changes were implemented. See the providers guide for more information.
There are a few things you need to do to import resources into .tfstate. In the example below there are resources which can be imported within the module. You may need to modify these commands to the OS on which they will be running (Refer to the documentation for additional details).
- terraform import '
<path-to-module>
.azurerm_postgresql_flexible_server.postgresql_flexible_server["<postgreslq-flexible-server-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.DBforPostgreSQL/flexibleservers/<postgreslq-flexible-server-name>
'
- terraform import '
<path-to-module>
.azurerm_postgresql_flexible_server_database.postgresql_flexible_server_database["<postgreslq-flexible-server-name>
_<postgresql-flexible-server-database-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.DBforPostgreSQL/flexibleservers/<postgresql-flexible-server-name>
/databases/<postgresql-flexible-server-database-name>
'
- terraform import '
<path-to-module>
.azurerm_postgresql_flexible_server_configuration.postgresql_flexible_server_configuration["<postgreslq-flexible-server-name>
_<postgresql-flexible-server-configuration-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.DBforPostgreSQL/flexibleservers/<postgresql-flexible-server-name>
/configurations/<postgresql-flexible-server-configuration-name>
'
- terraform import '
<path-to-module>
.azurerm_postgresql_flexible_server_active_directory_administrator.postgresql_flexible_server_active_directory_administrator["<postgreslq-flexible-server-name>
_<postgresql-flexible-server-active-directory-administrator-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.DBforPostgreSQL/flexibleservers/<postgresql-flexible-server-name>
/administrators/<postgresql-flexible-server-active-directory-administrator-name>
'
- terraform import '
<path-to-module>
.azurerm_monitor_diagnostic_setting.diagnostic_setting["<postgresql-server-name>
_<diag-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.DBforPostgreSQL/flexibleservers/<postgresql-flexible-server-name>
/databases/<postgresql-flexible-database-name>
|<diag-name>
'
- terraform import '
<path-to-module>
.module.private_endpoint.azurerm_private_endpoint.private_endpoint["<private-endpoint-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/privateEndpoints/<private-endpoint-name>
'
NOTE:
<path-to-module>
is terraform logical path from root. e.g. module.postgresql_flexible_server
Output Name | Value | Comment |
---|---|---|
outputs | name | |
id | ||
fqdn | ||
databases | PostgreSQL Flexible Database outputs | |
name | ||
id |
In the example below, outputted id of the deployed PostgreSQL Flexible Server module is used as a value for the scope variable in Role Assignment resource.
module "pgsql" {
source = "git@github.com:Seyfor-CSC/mit.postgresql-flexible-server.git?ref=v1.0.0"
config = [
{
name = "seyterraformnepgsql01"
location = "northeurope"
resource_group_name = "SEY-TERRAFORM-NE-RG01"
version = "14"
sku_name = "GP_Standard_D4s_v3"
administrator_login = "adminuser"
administrator_password = "P@ssword1234"
storage_mb = "32768"
}
]
}
data "azurerm_client_config" "azurerm_client_config" {
}
resource "azurerm_role_assignment" "role_assignment" {
scope = module.pgsql.outputs.seyterraformnepgsql01.id # This is how to use output values
role_definition_name = "Contributor"
principal_id = data.azurerm_client_config.azurerm_client_config.object_id
}
This module has a lifecycle block set up like this:
lifecycle {
ignore_changes = [
administrator_login,
administrator_password,
zone
]
}
We currently log no issues in this module.