Broonix Broonix - 1 year ago 92
Java Question

Spring-boot Amazon Elastic Beanstalk ignores 'SPRING_APPLICATION_JSON'

I've tried with both jar and war versions of my app, but no matter what I do

is ignored when deployed on Elastic Beanstalk. When testing locally using the same jar this works.

export SPRING_APPLICATION_JSON='{"server": { "port": 5000 } }'
java -jar my-app-1.0.1-SNAPSHOT.jar

... snip useless output
2016-07-05 12:18:02.877 INFO 10654 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 5000 (http)
2016-07-05 12:18:02.886 INFO 10654 --- [ main] : Started MyApplication in 22.827 seconds (JVM running for 23.514)

When setting the same JSON on AWS in Elastic Beanstalk (jar version shown)

enter image description here

But when the app launches with in AWS. The logs show it is not seeing the updated configuration value for

2016-07-05 15:58:33.511 INFO 2267 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-07-05 15:58:33.520 INFO 2267 --- [ main] : Started MyApplication in 37.746 seconds (JVM running for 47.043)

Why does this work locally but not on Elastic Beanstalk?

Answer Source

So after some reading and testing. It turns out this is a bug in the Elastic Beanstalk user-interface. Any property that requires quote will not work. This the same as How to config Meteor on AWS/EBS using METEOR_SETTINGS environment variable

I did work around the issue using .ebextensions. Which properly lets you insert escaped values.

    value: {"server":{"port": 5000}}