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.

  1. i set env variable cleartext

    $ export libmysql_enable_cleartext_plugin=1 
  2. i create rds certificate file

    $curl https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem > /home/ubuntu/rds-cert.pem 
  3. 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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -