7

I have a rails elastic beanstalk application with two environments, staging and production. When creating the application and staging environment with eb init i created a database instance. I used the eb console to create the production environment and created a new database instance which i perceive is obviously a wrong move.

How do i make my two environments share the same database instance? If that happens, how about when i update the database migrations in my app and deploy to the staging; it means my users would see it because the same database is used by staging environment.

How to i handle this issue?

I also noticed git aws.push doesn't overwrite my database but it doesn't remove rolled back migrations. Am i missing something?

1 Answer 1

5

I would recommend to you following option: Create rds instance outside of the elastic beanstalk environment. Create separate schemas for production and staging. Pass connections strings to your EBS application. Shared rds instance between EBS environments will help to you:

  1. Decrease cost of your environment, because to have several rds instances running is expensive.

  2. Help to you isolate production and staging environments.

Sign up to request clarification or add additional context in comments.

3 Comments

If i want to agree with you, how do i push my database from localhost independently to the new RDS instance? Remember its rails and a <code>git aws.push</code> does the deployment but with your solution not anymore. So how?
You can add to your application folder .ebextentions with config files which will contain configuration settings like connection string to db and scripts to run migrations. I would suggest to read article: docs.aws.amazon.com/elasticbeanstalk/latest/dg/…
I will try to explain my idea one more time be steps: 1. You can manually create rds instance and schemas for production and staging. 2. You can add to your application elastic beanstalk configuration files, where you can define connection string for current database related with staging or production, also you can define here commands for running migrations. 3. To do git aws.push :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.