This Terraform module creates a Azure PostgreSQL Database.
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-rg"
location = "West Europe"
}
module "postgresql" {
source = "Azure/postgresql/azurerm"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
server_name = "example-server"
sku_name = "GP_Gen5_2"
storage_mb = 5120
backup_retention_days = 7
geo_redundant_backup_enabled = false
administrator_login = "login"
administrator_password = "password"
server_version = "9.5"
ssl_enforcement_enabled = true
public_network_access_enabled = true
db_names = ["my_db1", "my_db2"]
db_charset = "UTF8"
db_collation = "English_United States.1252"
firewall_rule_prefix = "firewall-"
firewall_rules = [
{ name = "test1", start_ip = "10.0.0.5", end_ip = "10.0.0.8" },
{ start_ip = "127.0.0.0", end_ip = "127.0.1.0" },
]
vnet_rule_name_prefix = "postgresql-vnet-rule-"
vnet_rules = [
{ name = "subnet1", subnet_id = "<subnet_id>" }
]
tags = {
Environment = "Production",
CostCenter = "Contoso IT",
}
postgresql_configurations = {
backslash_quote = "on",
}
depends_on = [azurerm_resource_group.example]
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "example-rg"
location = "West Europe"
}
module "postgresql" {
source = "Azure/postgresql/azurerm"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
server_name = "example-server"
sku_name = "GP_Gen5_2"
storage_mb = 5120
backup_retention_days = 7
geo_redundant_backup_enabled = false
administrator_login = "login"
administrator_password = "password"
server_version = "9.5"
ssl_enforcement_enabled = true
public_network_access_enabled = true
db_names = ["my_db1", "my_db2"]
db_charset = "UTF8"
db_collation = "English_United States.1252"
firewall_rule_prefix = "firewall-"
firewall_rules = [
{ name = "test1", start_ip = "10.0.0.5", end_ip = "10.0.0.8" },
{ start_ip = "127.0.0.0", end_ip = "127.0.1.0" },
]
vnet_rule_name_prefix = "postgresql-vnet-rule-"
vnet_rules = [
{ name = "subnet1", subnet_id = "<subnet_id>" }
]
tags = {
Environment = "Production",
CostCenter = "Contoso IT",
}
postgresql_configurations = {
backslash_quote = "on",
}
}
We provide 2 ways to build, run, and test the module on a local development machine. Native (Mac/Linux) or Docker.
We provide simple script to quickly set up module development environment:
$ curl -sSL https://raw.githubusercontent.com/Azure/terramodtest/master/tool/env_setup.sh | sudo bash
Then simply run it in local shell:
$ cd $GOPATH/src/{directory_name}/
$ ./test.sh full
We provide a Dockerfile to build a new image based FROM
the microsoft/terraform-test
Docker hub image which adds additional tools / packages specific for this module (see Custom Image section). Alternatively use only the microsoft/terraform-test
Docker hub image by using these instructions.
$ docker build --build-arg BUILD_ARM_SUBSCRIPTION_ID=$ARM_SUBSCRIPTION_ID --build-arg BUILD_ARM_CLIENT_ID=$ARM_CLIENT_ID --build-arg BUILD_ARM_CLIENT_SECRET=$ARM_CLIENT_SECRET --build-arg BUILD_ARM_TENANT_ID=$ARM_TENANT_ID -t azure-postgresql .
This runs the local validation:
$ docker run --rm azure-postgresql /bin/bash -c "bundle install && rake build"
This runs the full tests (deploys resources into your Azure subscription):
$ docker run --rm azure-postgresql /bin/bash -c "bundle install && rake full"
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.