Skip to content

Support database parameter in postgresql_server and postgresql_user_mapping resources #542

Open
@bcmedeiros

Description

@bcmedeiros

I'm trying to create the following server resource after creating my fdw extension:

resource "postgresql_extension" "mysql_fdw" {
  name     = "mysql_fdw"
  database = postgresql_database.this.name
  schema   = "public"

  drop_cascade = var.drop_cascade
}

resource "postgresql_server" "mysql1" {
  fdw_name     = "mysql_fdw"
  server_name  = "mysql1"
  server_owner = postgresql_role.owner.name

  options = {
    host = "localhost"
    port = "3306"

    fetch_size    = 1000
    reconnect     = true
    character_set = "UTF-8"
  }

  drop_cascade = var.drop_cascade
  depends_on   = [postgresql_extension.mysql_fdw]
}

It fails with the following error:

│ Error: pq: foreign-data wrapper "mysql_fdw" does not exist
│ 
│   with module.pg1.module.stack_db.postgresql_server.mysql1,
│   on modules/database/main.tf line 130, in resource "postgresql_server" "mysql1":
│  130: resource "postgresql_server" "mysql1" {

Running the following query works, though, so this error seems to be a limitation of either this connector or the pg Go library.

CREATE SERVER mysql_main
    FOREIGN DATA WRAPPER mysql_fdw
    OPTIONS (host 'localhost', port '3306');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions