Install Java JRE
$ sudo apt-get install openjdk-6-jre
Make sure JAVA_HOME is set
$ export JAVA_HOME=/usr
$ echo $JAVA_HOME
$ export JAVA_HOME=/usr
$ echo $JAVA_HOME
$ $JAVA_HOME/bin/java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Setup Amazon RDS Heroku CLI tools
http://docs.aws.amazon.com/AmazonRDS/latest/CommandLineReference/StartCLI.html
Download RDS CLI tools:
http://aws.amazon.com/developertools/2928
Unzip tools to /usr/local
$ export AWS_RDS_HOME=/usr/local/RDSCli-1.14.001/
$ export PATH=$PATH:$AWS_RDS_HOME/bin
$ export AWS_CREDENTIAL_FILE=/usr/local/RDSCli-1.14.001/credential-file-path.template
Grant Heroku access to RDS using CLI tools:
(NOTE: 098166147350 is Heroku's secret number)
$ rds-authorize-db-security-group-ingress \
--db-security-group-name default \
--ec2-security-group-name default \
--ec2-security-group-owner-id 098166147350 \
--aws-credential-file $AWS_CREDENTIAL_FILE
SECGROUP default default
EC2-SECGROUP default sg-2**3 098166147350 authorizing
EC2-SECGROUP quicklaunch-1 sg-4**0 3***9 authorized
Set DATABASE_URL in Heroku config
heroku config:set DATABASE_URL=mysql2://username:password@rds-db-name.csisdr4twbmz.us-east-1.rds.amazonaws.com/database-name
Hi Nick, thanks for writing this up! I just wanted to note that Heroku no longer recommends using the AWS account id and security group to grant access to a RDS database: https://devcenter.heroku.com/changelog-items/353
ReplyDelete