https://github.com/launchbynttdata/tf-azurerm-module_reference-postgresql_server
https://github.com/launchbynttdata/tf-azurerm-module_reference-postgresql_server
azure infrastructure-as-code platform-automation reference terraform
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/launchbynttdata/tf-azurerm-module_reference-postgresql_server
- Owner: launchbynttdata
- License: apache-2.0
- Created: 2024-11-04T14:43:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-04-14T20:02:35.000Z (2 months ago)
- Last Synced: 2026-04-14T22:07:39.775Z (2 months ago)
- Topics: azure, infrastructure-as-code, platform-automation, reference, terraform
- Language: HCL
- Size: 117 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
- Notice: NOTICE
Awesome Lists containing this project
README
# tf-azurerm-module_reference-postgresql_server
[](https://opensource.org/licenses/Apache-2.0)
[](https://creativecommons.org/licenses/by-nc-nd/4.0/)
## Overview
This module deploys a Azure Database for PostgreSQL Flexible Server and any related resources
## Pre-Commit hooks
[.pre-commit-config.yaml](.pre-commit-config.yaml) file defines certain `pre-commit` hooks that are relevant to terraform, golang and common linting tasks. There are no custom hooks added.
`commitlint` hook enforces commit message in certain format. The commit contains the following structural elements, to communicate intent to the consumers of your commit messages:
- **fix**: a commit of the type `fix` patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
- **feat**: a commit of the type `feat` introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
- **BREAKING CHANGE**: a commit that has a footer `BREAKING CHANGE:`, or appends a `!` after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
footers other than BREAKING CHANGE: may be provided and follow a convention similar to git trailer format.
- **build**: a commit of the type `build` adds changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- **chore**: a commit of the type `chore` adds changes that don't modify src or test files
- **ci**: a commit of the type `ci` adds changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
- **docs**: a commit of the type `docs` adds documentation only changes
- **perf**: a commit of the type `perf` adds code change that improves performance
- **refactor**: a commit of the type `refactor` adds code change that neither fixes a bug nor adds a feature
- **revert**: a commit of the type `revert` reverts a previous commit
- **style**: a commit of the type `style` adds code changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- **test**: a commit of the type `test` adds missing tests or correcting existing tests
Base configuration used for this project is [commitlint-config-conventional (based on the Angular convention)](https://github.com/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional#type-enum)
If you are a developer using vscode, [this](https://marketplace.visualstudio.com/items?itemName=joshbolduc.commitlint) plugin may be helpful.
`detect-secrets-hook` prevents new secrets from being introduced into the baseline. TODO: INSERT DOC LINK ABOUT HOOKS
In order for `pre-commit` hooks to work properly
- You need to have the pre-commit package manager installed. [Here](https://pre-commit.com/#install) are the installation instructions.
- `pre-commit` would install all the hooks when commit message is added by default except for `commitlint` hook. `commitlint` hook would need to be installed manually using the command below
```
pre-commit install --hook-type commit-msg
```
## To test the resource group module locally
1. For development/enhancements to this module locally, you'll need to install all of its components. This is controlled by the `configure` target in the project's [`Makefile`](./Makefile). Before you can run `configure`, familiarize yourself with the variables in the `Makefile` and ensure they're pointing to the right places.
```
make configure
```
This adds in several files and directories that are ignored by `git`. They expose many new Make targets.
2. _THIS STEP APPLIES ONLY TO MICROSOFT AZURE. IF YOU ARE USING A DIFFERENT PLATFORM PLEASE SKIP THIS STEP._ The first target you care about is `env`. This is the common interface for setting up environment variables. The values of the environment variables will be used to authenticate with cloud provider from local development workstation.
`make configure` command will bring down `azure_env.sh` file on local workstation. Devloper would need to modify this file, replace the environment variable values with relevant values.
These environment variables are used by `terratest` integration suit.
Service principle used for authentication(value of ARM_CLIENT_ID) should have below privileges on resource group within the subscription.
```
"Microsoft.Resources/subscriptions/resourceGroups/write"
"Microsoft.Resources/subscriptions/resourceGroups/read"
"Microsoft.Resources/subscriptions/resourceGroups/delete"
```
Then run this make target to set the environment variables on developer workstation.
```
make env
```
3. The first target you care about is `check`.
**Pre-requisites**
Before running this target it is important to ensure that, developer has created files mentioned below on local workstation under root directory of git repository that contains code for primitives/segments. Note that these files are `azure` specific. If primitive/segment under development uses any other cloud provider than azure, this section may not be relevant.
- A file named `provider.tf` with contents below
```
provider "azurerm" {
features {}
}
```
- A file named `terraform.tfvars` which contains key value pair of variables used.
Note that since these files are added in `gitignore` they would not be checked in into primitive/segment's git repo.
After creating these files, for running tests associated with the primitive/segment, run
```
make check
```
If `make check` target is successful, developer is good to commit the code to primitive/segment's git repo.
`make check` target
- runs `terraform commands` to `lint`,`validate` and `plan` terraform code.
- runs `conftests`. `conftests` make sure `policy` checks are successful.
- runs `terratest`. This is integration test suit.
- runs `opa` tests
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | ~> 1.0 |
| [azurerm](#requirement\_azurerm) | ~> 3.113 |
## Providers
No providers.
## Modules
| Name | Source | Version |
|------|--------|---------|
| [resource\_names](#module\_resource\_names) | terraform.registry.launch.nttdata.com/module_library/resource_name/launch | ~> 2.0 |
| [resource\_group](#module\_resource\_group) | terraform.registry.launch.nttdata.com/module_primitive/resource_group/azurerm | ~> 1.0 |
| [postgresql\_server](#module\_postgresql\_server) | terraform.registry.launch.nttdata.com/module_primitive/postgresql_server/azurerm | ~> 1.1 |
| [postgresql\_server\_configuration](#module\_postgresql\_server\_configuration) | terraform.registry.launch.nttdata.com/module_primitive/postgresql_server_configuration/azurerm | ~> 1.0 |
| [postgresql\_server\_ad\_administrator](#module\_postgresql\_server\_ad\_administrator) | terraform.registry.launch.nttdata.com/module_primitive/postgresql_server_ad_administrator/azurerm | ~> 1.0 |
| [private\_endpoint](#module\_private\_endpoint) | terraform.registry.launch.nttdata.com/module_primitive/private_endpoint/azurerm | ~> 1.0 |
| [monitor\_action\_group](#module\_monitor\_action\_group) | terraform.registry.launch.nttdata.com/module_primitive/monitor_action_group/azurerm | ~> 1.0.0 |
| [monitor\_metric\_alert](#module\_monitor\_metric\_alert) | terraform.registry.launch.nttdata.com/module_primitive/monitor_metric_alert/azurerm | ~> 2.0 |
## Resources
No resources.
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [resource\_names\_map](#input\_resource\_names\_map) | A map of key to resource\_name that will be used by tf-launch-module\_library-resource\_name to generate resource names |
map(object({
name = string
max_length = optional(number, 60)
})) | {
"postgresql_server": {
"max_length": 60,
"name": "psql"
},
"private_endpoint": {
"max_length": 80,
"name": "pe"
},
"private_service_connection": {
"max_length": 80,
"name": "pesc"
},
"resource_group": {
"max_length": 60,
"name": "rg"
}
} | no |
| [instance\_env](#input\_instance\_env) | Number that represents the instance of the environment. | `number` | `0` | no |
| [instance\_resource](#input\_instance\_resource) | Number that represents the instance of the resource. | `number` | `0` | no |
| [logical\_product\_family](#input\_logical\_product\_family) | (Required) Name of the product family for which the resource is created.
Example: org\_name, department\_name. | `string` | `"launch"` | no |
| [logical\_product\_service](#input\_logical\_product\_service) | (Required) Name of the product service for which the resource is created.
For example, backend, frontend, middleware etc. | `string` | `"database"` | no |
| [class\_env](#input\_class\_env) | (Required) Environment where resource is going to be deployed. For example. dev, qa, uat | `string` | `"dev"` | no |
| [use\_azure\_region\_abbr](#input\_use\_azure\_region\_abbr) | Abbreviate the region in the resource names | `bool` | `true` | no |
| [location](#input\_location) | Location of the Postgres Flexible Server | `string` | `"eastus"` | no |
| [sku\_name](#input\_sku\_name) | The name of the SKU used by this Postgres Flexible Server | `string` | `"B_Standard_B1ms"` | no |
| [create\_mode](#input\_create\_mode) | The creation mode. Possible values are Default, GeoRestore, PointInTimeRestore, Replica, and Update | `string` | `"Default"` | no |
| [postgres\_version](#input\_postgres\_version) | Version of the Postgres Flexible Server. Required when `create_mode` is Default | `string` | `"16"` | no |
| [server\_configuration](#input\_server\_configuration) | Map of configurations to apply to the postgres flexible server | `map(string)` | `{}` | no |
| [delegated\_subnet\_id](#input\_delegated\_subnet\_id) | The ID of the subnet to which the Postgres Flexible Server is delegated | `string` | `null` | no |
| [private\_dns\_zone\_id](#input\_private\_dns\_zone\_id) | The ID of the private DNS zone. Required when `delegated_subnet_id` is set | `string` | `null` | no |
| [public\_network\_access\_enabled](#input\_public\_network\_access\_enabled) | Whether or not public network access is allowed for this server | `bool` | `false` | no |
| [authentication](#input\_authentication) | active\_directory\_auth\_enabled = Whether or not Active Directory authentication is enabled for this server
password\_auth\_enabled = Whether or not password authentication is enabled for this server
tenant\_id = The tenant ID of the Active Directory to use for authentication | object({
active_directory_auth_enabled = optional(bool)
password_auth_enabled = optional(bool)
tenant_id = optional(string)
}) | `null` | no |
| [ad\_administrator](#input\_ad\_administrator) | tenant\_id = The tenant ID of the AD administrator
object\_id = The object ID of the AD administrator
principal\_name = The name of the princiapl to assign as AD administrator
principal\_type = The type of princiapl to assign as AD administrator | object({
tenant_id = string
object_id = string
principal_name = string
principal_type = string
}) | `null` | no |
| [administrator\_login](#input\_administrator\_login) | The administrator login for the Postgres Flexible Server.
Required when `create_mode` is Default and `authentication.password_auth_enabled` is true | `string` | `null` | no |
| [administrator\_password](#input\_administrator\_password) | The administrator password for the Postgres Flexible Server.
Required when `create_mode` is Default and `authentication.password_auth_enabled` is true | `string` | `null` | no |
| [backup\_retention\_days](#input\_backup\_retention\_days) | The backup retention days for the Postgres Flexible Server, between 7 and 35 days | `number` | `7` | no |
| [geo\_redundant\_backup\_enabled](#input\_geo\_redundant\_backup\_enabled) | Whether or not geo-redundant backups are enabled for this server | `bool` | `false` | no |
| [zone](#input\_zone) | The zone of the Postgres Flexible Server | `string` | `null` | no |
| [high\_availability](#input\_high\_availability) | mode = The high availability mode. Possible values are SameZone or ZoneRedundant
standby\_availability\_zone = The availability zone for the standby server | object({
mode = string
standby_availability_zone = optional(string)
}) | `null` | no |
| [identity\_ids](#input\_identity\_ids) | Specifies a list of User Assigned Managed Identity IDs to be assigned | `list(string)` | `null` | no |
| [maintenance\_window](#input\_maintenance\_window) | The maintenance window of the Postgres Flexible Server
day\_of\_week = The day of the week when maintenance should be performed
start\_hour = The start hour of the maintenance window
start\_minute = The start minute of the maintenance window | object({
day_of_week = optional(string, 0)
start_hour = optional(number, 0)
start_minute = optional(number, 0)
}) | {
"day_of_week": 0,
"start_hour": 0,
"start_minute": 0
} | no |
| [source\_server\_id](#input\_source\_server\_id) | The ID of the source Postgres Flexible Server to restore from. Required when `create_mode` is GeoRestore, PointInTimeRestore, or Replica | `string` | `null` | no |
| [storage\_mb](#input\_storage\_mb) | The storage capacity of the Postgres Flexible Server in megabytes | `number` | `32768` | no |
| [storage\_tier](#input\_storage\_tier) | The storage tier of the Postgres Flexible Server. Default value based on `storage_mb` | `string` | `null` | no |
| [tags](#input\_tags) | A mapping of tags to assign to the resource. | `map(string)` | `{}` | no |
| [create\_private\_endpoint](#input\_create\_private\_endpoint) | Whether or not to create a Private Endpoint for the Postgres Flexible Server | `bool` | `false` | no |
| [private\_endpoint\_subnet\_id](#input\_private\_endpoint\_subnet\_id) | The ID of the subnet to which the Postgres Flexible Server private endpoint is connected | `string` | `null` | no |
| [private\_endpoint\_dns\_zone\_ids](#input\_private\_endpoint\_dns\_zone\_ids) | A list of Private DNS Zone IDs to link with the Private Endpoint. | `list(string)` | `[]` | no |
| [private\_endpoint\_dns\_zone\_group\_name](#input\_private\_endpoint\_dns\_zone\_group\_name) | Specifies the Name of the Private DNS Zone Group. | `string` | `"postgresqlServer"` | no |
| [private\_endpoint\_is\_manual\_connection](#input\_private\_endpoint\_is\_manual\_connection) | Does the Private Endpoint require Manual Approval from the remote resource owner? Changing this forces a new resource
to be created. | `bool` | `false` | no |
| [private\_endpoint\_subresource\_names](#input\_private\_endpoint\_subresource\_names) | A list of subresource names which the Private Endpoint is able to connect to. subresource\_names corresponds to group\_id.
Possible values are detailed in the product documentation in the Subresources column.
https://docs.microsoft.com/azure/private-link/private-endpoint-overview#private-link-resource | `list(string)` | [
"postgresqlServer"
]
| no |
| [private\_endpoint\_request\_message](#input\_private\_endpoint\_request\_message) | A message passed to the owner of the remote resource when the private endpoint attempts to establish the connection
to the remote resource. The request message can be a maximum of 140 characters in length.
Only valid if `is_manual_connection=true` | `string` | `""` | no |
| [action\_group](#input\_action\_group) | Optional action group configuration. If null, monitor\_action\_group module will not be created. | object({
name = string
short_name = string
email_receivers = optional(list(object({ name = string, email_address = string })), [])
arm_role_receivers = optional(list(object({
name = string
role_id = string
object_id = string
use_common_alert = optional(bool, false)
})), [])
}) | `null` | no |
| [resource\_group\_name](#input\_resource\_group\_name) | Optional resource group name for monitor resources. If empty, the generated resource\_group name is used. | `string` | `""` | no |
| [action\_group\_ids](#input\_action\_group\_ids) | List of pre-existing Action Group resource IDs to attach to alert rules (in addition to any created by this module). | `list(string)` | `[]` | no |
| [metric\_alerts](#input\_metric\_alerts) | Map of metric alert definitions for PostgreSQL server monitoring. Each alert must define either criteria or dynamic\_criteria. | map(object({
description = string
action_groups = optional(set(string), [])
frequency = optional(string, "PT1M")
severity = optional(number, 3)
enabled = optional(bool, true)
webhook_properties = optional(map(string))
criteria = optional(list(object({
metric_namespace = string
metric_name = string
aggregation = string
operator = string
threshold = number
skip_metric_validation = optional(bool, false)
dimensions = optional(list(object({
name = string
operator = string
values = list(string)
})))
})))
dynamic_criteria = optional(object({
metric_namespace = string
metric_name = string
aggregation = string
operator = string
alert_sensitivity = string
ignore_data_before = optional(string)
skip_metric_validation = optional(bool, false)
dimensions = optional(list(object({
name = string
operator = string
values = list(string)
})))
}))
})) | `{}` | no |
| [auto\_grow\_enabled](#input\_auto\_grow\_enabled) | storage auto-grow for PostgreSQL Flexible Server. | `bool` | `false` | no |
## Outputs
| Name | Description |
|------|-------------|
| [id](#output\_id) | n/a |
| [name](#output\_name) | n/a |
| [fqdn](#output\_fqdn) | n/a |
| [resource\_group\_name](#output\_resource\_group\_name) | n/a |
| [admin\_tenant\_id](#output\_admin\_tenant\_id) | n/a |
| [admin\_object\_id](#output\_admin\_object\_id) | n/a |
| [admin\_principal\_name](#output\_admin\_principal\_name) | n/a |
| [delegated\_subnet\_id](#output\_delegated\_subnet\_id) | n/a |
| [private\_dns\_zone\_id](#output\_private\_dns\_zone\_id) | n/a |
| [source\_server\_id](#output\_source\_server\_id) | n/a |
| [server\_configuration](#output\_server\_configuration) | n/a |