Random5000
Random5000

Reputation: 1670

How do you remove an RDS data layer from an Elastic Beanstalk environment

How do you remove an RDS database from an Elastic Beanstalk environment?

There doesn't appear to be an option to do this. I understand I can create an EB environment and have it create an RDS server with it, which we did. Now we just want to get raid of the RDS server by itself but leave the app servers running. I don't see how we're suppose to do this unless I just delete it from the RDS GUI, but I'd think the proper way to do it is remove it from the EB environment.

Upvotes: 36

Views: 8161

Answers (5)

Vasu
Vasu

Reputation: 31

You can decouple the RDS which will not impact the health of the EB environment and then you can do the application change to not use the RDS!

Ref:https://aws.amazon.com/about-aws/whats-new/2021/10/aws-elastic-beanstalk-database-decoupling-elastic-beanstalk-environment/

Upvotes: 0

jcasner
jcasner

Reputation: 324

I found a way to do this using the EB CLI that does not involve creating a replacement EB environment. For my use case, it was much more practical to modify the existing EB Environment and not have to go through the extra steps (and wait time) associated with creating a new environment and making sure all the settings propagated correctly.

TL;DR: Using the eb config feature, you can modify the settings for your existing environment and it will apply the change correctly.

Steps:

  1. Enable termination protection on my RDS instance
  2. Update ENV VARS for the EB environment to pass the hostname and port (once decoupled, ElasticBeanstalk will no longer provide these automatically in the preconfigured RDS_HOSTNAME and RDS_PORT env vars).
  3. Run eb config to open an editor. In the aws:rds:dbinstance section (for me, it was at the bottom), change DBDeletionPolicy to Retain
  4. Save and exit
  5. EB will automatically update your environment configuration
  6. Run eb config to open an editor. In the aws:rds:dbinstance section, change HasCoupledDatabase to 'false'
  7. Save and exit
  8. EB will automatically update your environment configuration

Original post for this solution: https://repost.aws/knowledge-center/decouple-rds-from-beanstalk#COG3pCkfJlRKa9_W9f6Bd7Xw

Upvotes: 0

Mohammad Hassany
Mohammad Hassany

Reputation: 983

Now you can decouple the database from your environment.

Then it will follow the data retention policy you have set for it.

https://aws.amazon.com/premiumsupport/knowledge-center/decouple-rds-from-beanstalk/

Upvotes: 0

Dario Seidl
Dario Seidl

Reputation: 4640

It's 2019 and still not possible to remove an RDS database from an Elastic Beanstalk environment. I wish I had known this earlier.

Anyway ... here are the general steps necessary to create a new environment without a managed RDS DB (based on the same thread from the AWS forum):

  1. Create a snapshot of your RDS DB and create a new RDS DB from it. This does not retain the security group, parameter group, or options of your DB. So it might be preferable to create a new empty RDS DB where you can configure everything and then restore the contents from a DB dump like mysqldump.

  2. Save a configuration of your Elastic Beanstalk env and download it from your S3 EBS bucket under resources/templates/<your-app-name>/.

  3. Modify the config to remove all references to RDS, and upload the modified file to your S3 bucket.

  4. Create a new environment from the saved configuration. You should now have an env without a managed RDS DB. Some settings might not be carried over in this process. For example, I had to reconfigure the load balancer for my new env.

  5. Once everything is working in the new env you can use "Swap Environment URLs" or point your DNS record to the new load balancer.

Upvotes: 7

Jo&#227;o Paulo Motta
Jo&#227;o Paulo Motta

Reputation: 3902

According to this answer on Amazon aws forums:

There is currently no way to remove RDS from an Elastic Beanstalk configuration. You would need to create a new Elastic Beanstalk application configuration that excludes the RDS configuration, launch your app in this new environment, and then change DNS to point to the new environment.

https://forums.aws.amazon.com/message.jspa?messageID=469364

Upvotes: 22

Related Questions