Skip to content

Terraform module to create and configure Scaleway Databases. Create RDB instances with managed databases, user creation and ACLs support.

Notifications You must be signed in to change notification settings

particuleio/terraform-scaleway-database

Repository files navigation

terraform-scaleway-database

terraform-scaleway-database

Terraform module to create Databases using Scaleway's Managed Databases.

Create and configure the following:

  • Managed RDB Instances
  • Database Users
  • Database ACLs
  • Managed Databases

Usage

The module takes a map of objects for each database to configure.

# example with a single RDB instance configured with 2 managed databases
module "database" {
  source  = "particuleio/database/scaleway"
  version = "1.2.0"  # use latest version

  databases = {
    main = {
      node_type      = "DB-DEV-S"
      engine         = "PostgreSQL-11"

      dbs = ["default", "core"]
    }
  }
}

The locals.tf defines default values that are merged and overriden by each database definition in the databases map.

Examples

Multiple examples are available in the ./examples directory.

Below is an advanced usage of this module.

module "database" {
  source  = "particuleio/database/scaleway"
  version = "1.2.0"  # use latest version

  databases = {
    main = {
      name      = "database-with-multiple-dbs"
      node_type = "DB-DEV-S"
      engine    = "PostgreSQL-11"

      dbs = ["default", "admin", "internal"]

      acls = [
        {
          ip          = "1.2.3.4/32"
          description = "Specific ACL 1"
        },
        {
          ip          = "192.168.1.20/28"
          description = "Specific ACL 2"
        },
      ]

      users = [
        {
          username        = "application"
          password_length = 16
          is_admin        = false
        },
        {
          username        = "administrator"
          password_length = 24
          is_admin        = true
        },
      ]
    }
    metrics = {  # second RDB instance definition
      name      = "simple-database"
      node_type = "DB-DEV-S"
      engine    = "PostgreSQL-11"
    }
  }
}

Requirements

Name Version
terraform >= 0.13
scaleway ~> 2.0

Providers

Name Version
random n/a
scaleway ~> 2.0

Modules

No modules.

Resources

Name Type
random_password.this resource
scaleway_rdb_acl.this resource
scaleway_rdb_database.this resource
scaleway_rdb_instance.this resource
scaleway_rdb_user.this resource

Inputs

Name Description Type Default Required
databases The scaleway Database configurations map(any) n/a yes
region Region to be used with the scaleway provider string "fr-par" no
zone Zone to be used with the scaleway provider string "fr-par-1" no

Outputs

Name Description
databases A map of each created scaleway_rdb_instance with each var.databases definition as key
instances A map of each created scaleway_rdb_instance with each var.databases definition as key
this A map of the scaleway_rdb_database (including their users) and scaleway_rdb_instance resources grouped by databases definitions