How can I configure RDS Mysql password, in case it is stored in AWS secret manager?

Viewed 138

This is my code, any help would be appreciated, thank you

<?php
define('HOST', "rdjxgve3dr5txt.cnn3hxxbkiiq.us-east-2.rds.amazonaws.com");
define('DBUSER', "Admin");
define('PASS', ".??????????");
define('DB', "myexample");
define('PORT', 3306);

$link=mysqli_connect(HOST,DBUSER,PASS,DB,PORT);

// Check connection
if (mysqli_connect_errno($link)){
    echo "Failure to connect: " . mysqli_connect_error();
}
?>
1 Answers

Generally, in you application you would use AWS PHP SDK to get the password from the Secret Manager using getSecretValue.

Once obtained you would probably need to cache it somewhere as not to query the manager for every single request. To access the secret manger from your instance, you would also need an instance role with necessary permissions.

Related