Michaël Gallego

This is my blog. What can you expect here? Well... Zend Framework 2, Amazon AWS...






Do not associate RDS instance with Beanstalk environment

Elastic Beanstalk allows you to associate a RDS instance when you create a new environment. However, I recommend you NOT to do so in production.

First, here are some pros of doing it:

  • Elastic Beanstalk automatically creates the RDS instance, as well as the properly configured security group.
  • Environment variables are injected into all your EC2 instances (like RDS_HOSTNAME, RDS_USERNAME…).

However, there is a big con that, to me, make it unusable in production: now, the RDS is associated with your environment. This means that if for whatever reason you need to rebuild the environment (for instance to update the Elastic Beanstalk AMI), you’re stuck because Elastic Beanstalk will delete any associated resource (like your RDS instance). You then need to create a snapshot of the RDS instance, and recreate a new one from it. This will lead to some downtime.

The best way, to my opinion, is to create the RDS instance separately, and manually inject the RDS environment variables into the newly created environment, using the Elastic Beanstalk GUI tool, for instance. This is much more flexible!