Skip to content

Commit 2ecb3af

Browse files
authored
Merge pull request #1 from kumarvna/develop
final configuration for version 1.0.0
2 parents 90c5612 + 35cb80d commit 2ecb3af

File tree

9 files changed

+852
-1
lines changed

9 files changed

+852
-1
lines changed

README.md

Lines changed: 256 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Azure Database for PostgreSQL Terraform Module
2+
3+
Azure Database for PostgreSQL Single Server is a fully managed database service with minimal requirements for customizations of database. The single server platform is designed to handle most of the database management functions such as patching, backups, high availability, security with minimal user configuration and control. The architecture is optimized for built-in high availability with 99.99% availability on single availability zone. It supports community version of PostgreSQL 9.5, 9,6, 10, and 11.
4+
5+
## Module Usage
6+
7+
```terraform
8+
module "postgresql-db" {
9+
source = "kumarvna/postgresql-db/azurerm"
10+
version = "1.0.0"
11+
12+
# By default, this module will create a resource group
13+
# proivde a name to use an existing resource group and set the argument
14+
# to `create_resource_group = false` if you want to existing resoruce group.
15+
# If you use existing resrouce group location will be the same as existing RG.
16+
create_resource_group = false
17+
resource_group_name = "rg-shared-westeurope-01"
18+
location = "westeurope"
19+
20+
# PostgreSQL Server and Database settings
21+
postgresql_server_name = "mypostgresdbsrv01"
22+
23+
postgresql_server_settings = {
24+
sku_name = "GP_Gen5_8"
25+
storage_mb = 640000
26+
version = "9.6"
27+
# default admin user `sqladmin` and can be specified as per the choice here
28+
# by default random password created by this module. required password can be specified here
29+
admin_username = "postgresadmin"
30+
admin_password = "H@Sh1CoR3!"
31+
# Database name, charset and collection arguments
32+
database_name = "demo-postgres-db"
33+
charset = "UTF8"
34+
collation = "English_United States.1252"
35+
# Storage Profile and other optional arguments
36+
auto_grow_enabled = true
37+
backup_retention_days = 7
38+
geo_redundant_backup_enabled = true
39+
public_network_access_enabled = true
40+
ssl_enforcement_enabled = true
41+
ssl_minimal_tls_version_enforced = "TLS1_2"
42+
}
43+
44+
# PostgreSQL Server Parameters
45+
# For more information: https://bit.ly/3dbYTtB
46+
postgresql_configuration = {
47+
backslash_quote = "on"
48+
}
49+
50+
# Use Virtual Network service endpoints and rules for Azure Database for PostgreSQL
51+
subnet_id = var.subnet_id
52+
53+
# The URL to a Key Vault custom managed key
54+
key_vault_key_id = var.key_vault_key_id
55+
56+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
57+
enable_threat_detection_policy = true
58+
log_retention_days = 30
59+
email_addresses_for_alerts = ["user@example.com", "firstname.lastname@example.com"]
60+
61+
# AD administrator for an Azure database for PostgreSQL
62+
# Allows you to set a user or group as the AD administrator for PostgreSQL server
63+
ad_admin_login_name = "firstname.lastname@example.com"
64+
65+
# (Optional) To enable Azure Monitoring for Azure PostgreSQL database
66+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
67+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
68+
69+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
70+
firewall_rules = {
71+
access-to-azure = {
72+
start_ip_address = "0.0.0.0"
73+
end_ip_address = "0.0.0.0"
74+
},
75+
desktop-ip = {
76+
start_ip_address = "49.204.228.223"
77+
end_ip_address = "49.204.228.223"
78+
}
79+
}
80+
81+
# Tags for Azure Resources
82+
tags = {
83+
Terraform = "true"
84+
Environment = "dev"
85+
Owner = "test-user"
86+
}
87+
}
88+
```
89+
90+
## Terraform Usage
91+
92+
To run this example you need to execute following Terraform commands
93+
94+
```hcl
95+
terraform init
96+
97+
terraform plan
98+
99+
terraform apply
100+
```
101+
102+
Run `terraform destroy` when you don't need these resources.

examples/PostgreSQL_Server/main.tf

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
module "postgresql-db" {
2+
// source = "kumarvna/postgresql-db/azurerm"
3+
// version = "1.0.0"
4+
source = "../../"
5+
6+
# By default, this module will create a resource group
7+
# proivde a name to use an existing resource group and set the argument
8+
# to `create_resource_group = false` if you want to existing resoruce group.
9+
# If you use existing resrouce group location will be the same as existing RG.
10+
create_resource_group = false
11+
resource_group_name = "rg-shared-westeurope-01"
12+
location = "westeurope"
13+
14+
# PostgreSQL Server and Database settings
15+
postgresql_server_name = "mypostgresdbsrv01"
16+
17+
postgresql_server_settings = {
18+
sku_name = "GP_Gen5_8"
19+
storage_mb = 640000
20+
version = "9.6"
21+
# default admin user `sqladmin` and can be specified as per the choice here
22+
# by default random password created by this module. required password can be specified here
23+
admin_username = "postgresadmin"
24+
admin_password = "H@Sh1CoR3!"
25+
# Database name, charset and collection arguments
26+
database_name = "demo-postgres-db"
27+
charset = "UTF8"
28+
collation = "English_United States.1252"
29+
# Storage Profile and other optional arguments
30+
auto_grow_enabled = true
31+
backup_retention_days = 7
32+
geo_redundant_backup_enabled = true
33+
public_network_access_enabled = true
34+
ssl_enforcement_enabled = true
35+
ssl_minimal_tls_version_enforced = "TLS1_2"
36+
}
37+
38+
# PostgreSQL Server Parameters
39+
# For more information: https://bit.ly/3dbYTtB
40+
postgresql_configuration = {
41+
backslash_quote = "on"
42+
}
43+
44+
# Use Virtual Network service endpoints and rules for Azure Database for PostgreSQL
45+
subnet_id = var.subnet_id
46+
47+
# The URL to a Key Vault custom managed key
48+
key_vault_key_id = var.key_vault_key_id
49+
50+
# To enable Azure Defender for database set `enable_threat_detection_policy` to true
51+
enable_threat_detection_policy = true
52+
log_retention_days = 30
53+
email_addresses_for_alerts = ["user@example.com", "firstname.lastname@example.com"]
54+
55+
# AD administrator for an Azure database for PostgreSQL
56+
# Allows you to set a user or group as the AD administrator for PostgreSQL server
57+
ad_admin_login_name = "firstname.lastname@example.com"
58+
59+
# (Optional) To enable Azure Monitoring for Azure PostgreSQL database
60+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
61+
log_analytics_workspace_name = "loganalytics-we-sharedtest2"
62+
63+
# Firewall Rules to allow azure and external clients and specific Ip address/ranges.
64+
firewall_rules = {
65+
access-to-azure = {
66+
start_ip_address = "0.0.0.0"
67+
end_ip_address = "0.0.0.0"
68+
},
69+
desktop-ip = {
70+
start_ip_address = "49.204.228.223"
71+
end_ip_address = "49.204.228.223"
72+
}
73+
}
74+
75+
# Tags for Azure Resources
76+
tags = {
77+
Terraform = "true"
78+
Environment = "dev"
79+
Owner = "test-user"
80+
}
81+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "key_vault_key_id" {
2+
description = "The URL to a Key Vault Key"
3+
default = null
4+
}
5+
6+
variable "subnet_id" {
7+
description = "The resource ID of the subnet"
8+
default = null
9+
}

examples/complete/main.tf

Whitespace-only changes.

graph.png

322 KB
Loading

0 commit comments

Comments
 (0)