Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yngveh committed Mar 26, 2021
1 parent c598310 commit 9237553
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ Terraform module to create a PostgreSQL server in Azure with set of databases an

## Limitations

Due to some limitations in terraform it does not handle the postgresql provider correctly. It will fail on first deployment due to server host does not exist. Only way to fix that now is to comment out the postgresql provider, postgresql resources and postgresql output. Then run first time to create server and comment in other resources and run again.
Password is mandatory for database users. Set to null for auto generated password.

## Usage

Examples of usage for this terraform module can be found under the example directory.

Example showing deployment of a server with single database using [tau](https://github.com/avinor/tau)

```terraform
module {
source = "avinor/postgresql/azurerm"
version = "1.0.0"
version = "2.0.4"
}
inputs {
Expand All @@ -22,7 +24,6 @@ inputs {
location = "westeurope"
sku = {
name = "B_Gen5_1"
capacity = 1
tier = "Basic"
family = "Gen5"
Expand All @@ -35,7 +36,8 @@ inputs {
collation = "English_United States.1252"
users = [
{
name = "a_user"
name = "a_user"
password = null
grants = [
{
object_type : "database"
Expand Down
3 changes: 1 addition & 2 deletions examples/diagnostics/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module "simple" {
location = "westeurope"

sku = {
name = "B_Gen5_1"
capacity = 1
tier = "Basic"
family = "Gen5"
Expand All @@ -22,7 +21,7 @@ module "simple" {
collation = "English_United States.1252"
users = [
{
name = "a_user"
name = "a_user"
password = null
grants = [
{
Expand Down
1 change: 0 additions & 1 deletion examples/password/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module "simple" {
location = "westeurope"

sku = {
name = "B_Gen5_1"
capacity = 1
tier = "Basic"
family = "Gen5"
Expand Down
1 change: 0 additions & 1 deletion examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module "simple" {
location = "westeurope"

sku = {
name = "B_Gen5_1"
capacity = 1
tier = "Basic"
family = "Gen5"
Expand Down
25 changes: 19 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ variable "location" {

variable "sku" {
description = "SKU settings of server, see https://www.terraform.io/docs/providers/azurerm/r/postgresql_server.html for details."
type = object({ capacity = number, tier = string, family = string })
type = object({
capacity = number
tier = string
family = string
})
}

variable "storage_mb" {
Expand Down Expand Up @@ -60,13 +64,22 @@ variable "configuration" {

variable "diagnostics" {
description = "Diagnostic settings for those resources that support it. See README.md for details on configuration."
type = object({ destination = string, eventhub_name = string, logs = list(string), metrics = list(string) })
default = null
type = object({
destination = string
eventhub_name = string
logs = list(string)
metrics = list(string)
})
default = null
}

variable "network_rules" {
description = "Network rules restricing access to the postgresql server."
type = object({ ip_rules = list(string), subnet_ids = list(string), allow_access_to_azure_services = bool })
description = "Network rules restricting access to the postgresql server."
type = object({
ip_rules = list(string)
subnet_ids = list(string)
allow_access_to_azure_services = bool
})
default = {
ip_rules = []
subnet_ids = []
Expand All @@ -75,7 +88,7 @@ variable "network_rules" {
}

variable "databases" {
description = "List of databases and users with access to them. Assigning users require that the provisioner have access to database. Secret attribute is secret name for a keyvault secret for password, auto generated if null"
description = "List of databases and users with access to them. Assigning users require that the provisioner have access to database. Password is auto generated if null"
type = list(object({
name = string
charset = string
Expand Down

0 comments on commit 9237553

Please sign in to comment.