PHP code example of tacticmedia / rds-auth-middleware
1. Go to this page and download the library: Download tacticmedia/rds-auth-middleware library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tacticmedia / rds-auth-middleware example snippets
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\DriverManager;
use TacticMedia\RdsAuth\RdsAuthMiddleware;
use TacticMedia\RdsAuth\RdsIamTokenProvider;
use TacticMedia\RdsAuth\RdsSecretPasswordProvider;
$region = getenv('AWS_REGION') ?: 'us-east-1';
$middleware = new RdsAuthMiddleware(
new RdsIamTokenProvider($region),
new RdsSecretPasswordProvider($region),
getenv('RDS_IAM_USERNAME') ?: null, // null disables the IAM path
getenv('RDS_SECRET_ARN') ?: null, // null disables the refresh path
$cachePool, // any PSR-6 pool; omit to disable caching
);
$configuration = new Configuration();
$configuration->setMiddlewares([$middleware]);
$connection = DriverManager::getConnection($params, $configuration);