Skip to content

TaitoUnited/terraform-azurerm-databases

Repository files navigation

Azure databases

Example usage:

provider "azurerm" {
  features {}
}

module "databases" {
  source               = "TaitoUnited/databases/azurerm"
  version              = "1.0.0"

  resource_group_name  = "my-infrastructure"
  virtual_network_id   = module.network.virtual_network_id
  subnet_id            = module.network.internal_subnet_id

  postgresql_clusters  = yamldecode(file("${path.root}/../infra.yaml"))["postgresqlClusters"]
  mysql_clusters       = yamldecode(file("${path.root}/../infra.yaml"))["mysqlClusters"]

  # TODO: implement long-term backups
  long_term_backup_bucket = "my-backup"
}

Example YAML:

databaseBackupVault:
  enabled: true
  location: northeurope
  redundancy: LocallyRedundant
  softDelete: On
  softDeleteRetentionDurationInDays: 14

postgresqlClusters:
  - name: my-common-postgres
    location: northeurope
    version: "16"
    skuName: GP_Gen5_2
    autoGrowEnabled: true
    backupRetentionDays: 30
    geoRedundantBackupEnabled: true
    # Schedule in ISO 8601 formatted intervals (R = repeating, P1W = weekly)
    vaultBackupSchedule:
      - R/2024-06-01T02:00:00+00:00/P1W
    # Retention in ISO 8601 formatted durations (P4M = 4 months)
    vaultBackupRetention: P4M
    publicNetworkAccessEnabled: false
    authorizedNetworks:
      - start: 127.127.127.10
        end: 127.127.127.20
    extensions:
      - PGCRYPTO
      - POSTGIS
    adminUsername: admin

mysqlClusters:
  - name: my-common-mysql
    location: northeurope
    version: "8.0"
    skuName: GP_Gen5_2
    autoGrowEnabled: true
    backupRetentionDays: 30
    geoRedundantBackupEnabled: true
    publicNetworkAccessEnabled: false
    authorizedNetworks:
      - start: 127.127.127.10
        end: 127.127.127.20
    adminUsername: admin

YAML attributes:

Combine with the following modules to get a complete infrastructure defined by YAML:

TIP: Similar modules are also available for AWS, Google Cloud, and DigitalOcean. All modules are used by infrastructure templates of Taito CLI. See also Azure project resources, Full Stack Helm Chart, and full-stack-template.

Contributions are welcome!