Wednesday, October 07, 2020

Spring cloud param store Hoxton.SR6 to Hoxton.SR8 how to run locally

 

So your using aws param store to configure your application when deployed to docker/elastic beanstalk but ran into issues on doing testing after updates to remove cve issues.

before hand

at or before Hoxton.SR6 you only needed in test/resources/bootstrap.yml

aws.paramstore.enabled: false

But after updating to 
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
<dependency><scope>import</scope><groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version><type>pom</type></dependency>
<dependency><groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId></dependency>
<dependency><groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-aws-parameter-store-config</artifactId></dependency>

it now throws logs of errors and fails to boot, this sucks :'(
errors are:

see Log file output
lets work out where it broke. We first need to see what jar's were imported by our spring-cloud-dependencies

we do this by looking at 

https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies/Hoxton.SR6 to https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies/Hoxton.SR8

And we notice that that the aws cloud version incremented from 2.2.2 to 2.2.4

to see what changed we can do this on github by visiting the link below

https://github.com/spring-cloud/spring-cloud-aws/compare/v2.2.2.RELEASE...v2.2.4.RELEASE

What was added in the doc's which looked like it might be our problem.

|aws.paramstore.region | | If region value is not null or empty it will be used in creation of AWSSimpleSystemsManagement.

|aws.secretsmanager.region | | If region value is not null or empty it will be used in creation of AWSSecretsManager.

On application startup, for its internal purposes Spring Cloud AWS performs a check if application runs in AWS cloud environment

by using `EC2MetadataUtils` class provided by AWS SDK. Starting from version 1.11.678, AWS SDK logs a warning message with exception when this check is made outside of AWS environment.

This warning message can be hidden by setting `ERROR` logging level on `com.amazonaws.util.EC2MetadataUtils` class.

so it seems we now need to set a region to block auto region lookup even when we have the paramstore disabled, we also need to do it for the stack and region lookup outside of paramstore.

test/resources/bootstrap.yml

aws:
paramstore:
enabled: false
fail-fast: false
region: "ap-southeast-2"
secretmanager:
region: "ap-southeast-2"

cloud:
aws:
region:
auto: false
static: "ap-southeast-2"
stack:
auto: false
Now that we did this, we are now not crashing. Awesome :D

Hope this helps others including future me.