Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: how to use mfa repo config? #292

Open
elvanja opened this issue Oct 18, 2024 · 1 comment
Open

Q: how to use mfa repo config? #292

elvanja opened this issue Oct 18, 2024 · 1 comment

Comments

@elvanja
Copy link

elvanja commented Oct 18, 2024

Hi,

Our regular Ecto repo is configured like this (it fetches credentials from AWS based on some configured role):

# in runtime.exs
credentials = System.get_env("RDS_DB_IAM_ROLE_CREDENTIALS")

config :demo, Demo.Repo,
  configure: {Demo.Repo, :configure_with_auth_token, [credentials]}


# in repo.ex
defmodule Demo.Repo do
  use Ecto.Repo,
    otp_app: :demo,
    adapter: Ecto.Adapters.Postgres

  # Helper function to configure the connection with dynamically generated auth token for an IAM role
  def configure_with_auth_token(opts, credentials) do
    aws_credentials = :aws_credentials.get_credentials()
    # connects to AWS for token
    # rest of code omitted for brevity
    auth_token = rds_auth_token(aws_credentials)

    Keyword.put(opts, :password, auth_token)
  end
end

How can we do the same for event store?
Ideally it would be the same / similar mfa approach, but that does not work.

Thank you! 🙇🏼

@elvanja
Copy link
Author

elvanja commented Oct 18, 2024

P.S. the :configure comes from Postgrex, see https://hexdocs.pm/postgrex/Postgrex.SimpleConnection.html#start_link/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant