After creating a Java 8 Elastic Beanstalk instance with RDS, the RDS connection details are not visible as environment variables (they are visible on other instances that are running).
After running printenv command, the expectation was for these values to be available but they are not.
RDS_HOSTNAME=foo.com
RDS_USERNAME=foo
RDS_PASS=bar
These are required by the server config
database:
driverClass: com.mysql.jdbc.Driver
user: ${RDS_USERNAME}
password: ${RDS_PASSWORD}
url: jdbc:mysql://${RDS_HOSTNAME}/${RDS_DB_NAME}
During application firing they are not available, the logs shows a Java exception that it cannot find the environment variables.
io.dropwizard.configuration.UndefinedEnvironmentVariableException: The environment variable 'RDS_USERNAME' is not defined; could not substitute the expression '${RDS_USERNAME}'. at io.dropwizard.configuration.EnvironmentVariableLookup.lookup(EnvironmentVariableLookup.java:41) at org.apache.commons.lang3.text.StrSubstitutor.resolveVariable(StrSubstitutor.java:934) at org.apache.commons.lang3.text.StrSubstitutor.substitute(StrSubstitutor.java:855) at org.apache.commons.lang3.text.StrSubstitutor.substitute(StrSubstitutor.java:743) at org.apache.commons.lang3.text.StrSubstitutor.replace(StrSubstitutor.java:403) at io.dropwizard.configuration.SubstitutingSourceProvider.open(SubstitutingSourceProvider.java:39) at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:83) at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:124) at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:72) at io.dropwizard.cli.Cli.run(Cli.java:75) at io.dropwizard.Application.run(Application.java:93)
However if I run the following command on the ec2 instance
sudo /opt/elasticbeanstalk/bin/get-config environment
It prints the values out in JSON:
{"CONFIG":"dev.yml","RDS_HOSTNAME":"foo.com","RDS_PASSWORD":"foo","M2":"/usr/local/apache-maven/bin","M2_HOME":"/usr/local/apache-maven","RDS_DB_NAME":"foo","JAVA_HOME":"/usr/lib/jvm/java","RDS_USERNAME":"foo","GRADLE_HOME":"/usr/local/gradle","RDS_PORT":"3306"}
Any ideas how to restore these values for the ec2-user?
I have tried:
- Restarting the EB instance
- Rebuilding the instance
catthe values into a script that sets them aftereb deploy
Any ideas, why they are not visible on this particular instance?
Instance details
Environment details foo: foo-service
Application name: foo-service
Region: eu-west-2
Platform: arn:aws:elasticbeanstalk:eu-west-2::platform/Java 8 running on 64bit Amazon Linux/2.6.0
Tier: WebServer-Standard