Skip to content

Allow passing a function as password to @effect/sql-pg #6002

@smozely

Description

@smozely

What is the problem this feature would solve?

When working with Amazon RDS Postgres instances with IAM authentication, passwords are short-lived and need to be created each time they're connecting to the DB.

When not using effect, this can be accomplished by passing a function to the password param when creating the connection pool in the pg library.

We do something like this:

async function createIamAuthToken(host: string, port: number, user: string) {
  const signer = new Signer({ hostname: host, port: port, username: user });
  return await signer.getAuthToken();
}

const pool = new Pool({
  host: "",
  port: "",
  user: "",
  password: createIamAuthToken("", "", "")
    });

Which has been working successfully for us, but we are looking at trying to use Effect more in our codebase.

What is the feature you are proposing to solve the problem?

Allow the types for passing a function for the password provided to @effect/sql-pg

What alternatives have you considered?

  • Another option would be being able to pass a fully constructed pool to @effect/sql-pg which could be useful for migrations to Effect like ours
  • It almost would just be a type error that we could ignore, except that password goes into Redacted.value(options.password)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions