Jay
Jay

Reputation: 57

Deploying spring boot to elasticbeanstalk and setting system properties

I'm trying to deploy a spring boot application (generated with teh jhipster yeoman template) to aws. I am having some success but find myself with a question of :

How do I configure the production profile to use the AWS specified system properties to get the database connection information assigned properly.

The AWS documentation just says set the databaseName, serverName, userName, password to the following to teh following:

System.getProperty("RDS_DB_NAME"); 
System.getProperty("RDS_USERNAME"); 
System.getProperty("RDS_PASSWORD"); 
System.getProperty("RDS_HOSTNAME");
System.getProperty("RDS_PORT");

I am using a yaml file to specify these parameters for Dev and prod mode and I find myself asking. How do I inject the above calls into my yaml file? in jruby on rails I'd do something like:

username: <%= System.getProperty("RDS_USERNAME") %>

in my yaml file. but seeing that this is Java I don't think this will work. or should I be thinking about this differently? It just seems like the easy place to do this should be in teh yaml file and a lot of my googling doesn't seem to be turning up much.

Any help would be appreciated.

Upvotes: 0

Views: 1129

Answers (2)

Jay
Jay

Reputation: 57

Thanks Julien,

any others the answer is quite simple.

If you are using a yaml file for your production settings and slurping the properties out through a RelaxedPropertyResolver you just need to do the following in your yaml:

databaseName: ${RDS_DB_NAME}
serverName: ${RDS_HOSTNAME}
username: ${RDS_USERNAME}
password: ${RDS_PASSWORD}

I'll open up an issue as I am also running into some other problems but just wanted to answer here too.

Upvotes: 1

Julien Dubois
Julien Dubois

Reputation: 3688

Have a look at how we set the properties for deploying on Heroku, it probably works the same:

https://github.com/jhipster/generator-jhipster/blob/master/heroku/templates/Procfile

BTW, I would love to have also a Beanstalk sub-generator, so if you succeed can you share it? You could add a ticket explaining what you did at https://github.com/jhipster/generator-jhipster/issues

Upvotes: 0

Related Questions