Skip to content

Instantly share code, notes, and snippets.

@rowan-m
Created March 20, 2013 15:13
Show Gist options
  • Save rowan-m/5205465 to your computer and use it in GitHub Desktop.
Save rowan-m/5205465 to your computer and use it in GitHub Desktop.
Pulling RDS config from an Elastic Beanstalk environment for Drupal
<?php
// ---8<--- SNIP ---8<---
if (isset(
$_SERVER['PARAM2'], $_SERVER['RDS_HOSTNAME'], $_SERVER['RDS_PORT'], $_SERVER['RDS_USERNAME'], $_SERVER['RDS_PASSWORD']
)) {
$databases = array(
'default' =>
array(
'default' =>
array(
'database' => $_SERVER['PARAM2'], // Set by you in the EB container
'username' => $_SERVER['RDS_USERNAME'],
'password' => $_SERVER['RDS_PASSWORD'],
'host' => $_SERVER['RDS_HOSTNAME'],
'port' => $_SERVER['RDS_PORT'],
'driver' => 'mysql',
'prefix' => '',
),
),
);
} else {
$databases = array(
'default' =>
array(
'default' =>
array(
'database' => 'dev_db',
'username' => 'dev_user',
'password' => 'dev_password',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
}
// ---8<--- SNIP ---8<---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment