What's the Perl DBI command syntax for connecting to mysql using AWS IAM authentication with a previously generated token? -
resolved: connection string needs have mysql_ssl=1 , mysql_ssl_ca_file:
$dbh = dbi->connect(qq[dbi:mysql:host=$host;dbname=$name;mysql_ssl=1;mysql_ssl_ca_file=<pem cert location>, $user, $token, { raiseerror => 1, autocommit => 0 });
no idea why keeps downvoting question..
i have connect mysql using aws iam authentication token password perl , python scripts. token generation easy , connecting python. can't find exact syntax using perl's dbi.
i set env variable cleartext
$ export libmysql_enable_cleartext_plugin=1
i create rds certificate file
$curl https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem > /home/ubuntu/rds-cert.pem
i try connect code:
token aws call below correct @ point - checked
#!/usr/bin/perl use strict; use warnings; use dbi; $token = `aws rds generate-db-auth-token --hostname <my hostname nere> --username <my username here> --region eu-west-1`; $token =~ s/\n$//; $dbname = 'my_db_name'; $user = 'my_user'; $dbh = dbi->connect(qq[dbi:mysql:host=$host;dbname=$dbname], $user, $token, { raiseerror => 1, autocommit => 0 });
i have tried several permutations of last line, end this:
failed: access denied user '<my user name here>'@'<aws instance ip here>' (using password: yes)
i realize might have include region, certificate location, etc, not finding examples of in dbi documentation or in stackoverflow.
Comments
Post a Comment