Skip to content

Unable to connect to RDS Proxy #201

Closed
@Octogonapus

Description

@Octogonapus

This is more of a question than a bug report. I'm not sure if the problem is in my code or not.

I'm trying to connect to an RDS MySQL DB via RDS Proxy and I'm unable to do so via MySQL.jl. Using the mysql CLI works fine. This shell code runs fine (connects and runs the SQL code):

nc -z $DB_ENDPOINT $DB_PORT && echo "can connect to DB endpoint" || echo "can't connect to DB endpoint"
nc -z $PROXY_ENDPOINT $DB_PORT && echo "can connect to proxy endpoint" || echo "can't connect to proxy endpoint"

echo "connecting to the DB endpoint via mysql CLI"
mysql --host=$DB_ENDPOINT --port=$DB_PORT --ssl-ca=/runtime/global-bundle.pem --ssl-mode=VERIFY_IDENTITY --enable-cleartext-plugin --user=$DB_USERNAME --password=$DB_PASSWORD < /runtime/debug.sql

echo "generating DB auth token"
db_auth_token=$(aws rds generate-db-auth-token --hostname $PROXY_ENDPOINT --port $DB_PORT --region $AWS_DEFAULT_REGION --username $DB_USERNAME)

echo "connecting to the proxy endpoint via mysql CLI"
mysql --host=$PROXY_ENDPOINT --port=$DB_PORT --ssl-ca=/runtime/AmazonRootCA1.pem --ssl-mode=VERIFY_IDENTITY --enable-cleartext-plugin --user=$DB_USERNAME --password=$db_auth_token < /runtime/debug.sql

So in summary, the mysql CLI can connect to both the DB endpoint and proxy endpoint just fine.

Here's my code to connect to the DB endpoint via MySQL.jl:

with_connection(;
    host = ENV["DB_ENDPOINT"],
    username = ENV["DB_USERNAME"],
    password = ENV["DB_PASSWORD"],
    unix_socket = "",
    db = "main",
    port = parse(Int, string(ENV["DB_PORT"])),
    ssl_ca = "/runtime/global-bundle.pem",
    ssl_verify_server_cert = true,
    ssl_enforce = true,
) do conn
    println(execute_df(conn, read("/runtime/debug.sql", String)))
end

with_connection passes all arguments to connect so for this example, they are the same.
As expected, this works fine.

Here's my code to connect to the proxy endpoint via MySQL.jl:

with_connection(;
    host = ENV["PROXY_ENDPOINT"],
    username = ENV["DB_USERNAME"],
    password = db_auth_token,
    unix_socket = "",
    db = "main",
    port = parse(Int, string(ENV["DB_PORT"])),
    ssl_ca = "/runtime/AmazonRootCA1.pem",
    ssl_verify_server_cert = true,
    ssl_enforce = true,
) do conn
    println(execute_df(conn, read("/runtime/debug.sql", String)))
end

AFAICT this should have the same behavior as the mysql CLI code.
However, this does not work; I get this error back:

│    (1045): Access denied for user 'root'@'<internal ip>' (using password: NO)
│    Stacktrace:
│      [1] connect
│        @ ~/.julia/packages/MySQL/LGSYW/src/api/capi.jl:12 [inlined]
│      [2] MySQL.Connection(host::String, user::String, passwd::SubString{String}, db::String, port::Int64, unix_socket::String; kw::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:ssl_ca, :ssl_verify_server_cert, :ssl_enforce), Tuple{String, Bool, Bool}}})
│        @ MySQL ~/.julia/packages/MySQL/LGSYW/src/MySQL.jl:34
│      [3] #connect#5
│        @ ~/.julia/packages/MySQL/LGSYW/src/MySQL.jl:288 [inlined]

Do you see anything wrong with my Julia code to open the connection to the proxy endpoint?

Julia v1.8.2. MySQL.jl v1.4.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions