Skip to content
Advertisement

How to use RDS environment properties attached to Elastic Beanstalk Environment – Java

I created an ElasticBeanstalk env with an RDS attached to it. The platform of the instance using Corretto 8 running on 64bit Amazon Linux 2.

It says here that the RDS settings are available as environment properties like RDS_HOSTNAME and here it states that in Java, we could retrieve them using System.getenv().

But when I try it on the EC2 instance, it returns null. Hence, when I use ${RDS_HOSTNAME} in my application.properties file, the spring app fails to start.

enter image description here

I see one tutorial doing quite the same with what I do here but I could not figure out what is wrong with my settings. Any ideas?

Advertisement

Answer

You have to export them first. You can try the following as root:

export $(cat /opt/elasticbeanstalk/deployment/env | xargs)
Advertisement