3

I'm struggling with my web application that I successfully deployed on AWS. Everything is working correctly on the web tier environment. However I have to add a worker tier environment to schedule background tasks. So now I have 2 environment for my AWS application. One that is a web tier and the other that is a worker tier. I didn't create a database for the worker tier because I want this environment to use the RDS database of the Web tier. How can I specify to the worker tier to use the RDS database of the web tier ?

Mubramaj
  • 641
  • 9
  • 14

1 Answers1

1

Elastic Beanstalk is not really the best solution for handling RDS far as I know. Having RDS instance tied to your ElasticBeanstalk environment will work well for dev/test, however tying the lifecycle of the database instance to the lifecycle of your application's environment is not really the best option.

I would recommend simply decoupling RDS and not adding it to ElasticBeanstalk, handle it separately. This approach will allow you to connect multiple environments to RDS instance, terminate an environment without affecting the database lifecycle, and perform continuous updates with blue/green deployment method approach.

You can pass DB details (host, port, user, password) as environment variables to your ElasticBeanstalk applications (might be problematic because of security risks).

Another alternative is to store connection string in S3 bucket that you control and allowing your EC2 instances access this S3 bucket via EC2 instance profiles.

You can find more information and examples how to handle this in Using Elastic Beanstalk with Amazon RDS docs.

If above doesn't work for you then it's probably time to look into CloudFormation to manage your application lifecycle, infrastructure and dependencies in a more controlled fashion.

Michal Gasek
  • 6,173
  • 1
  • 18
  • 20