Something New is Emerging

Ever wonder what life is really all about? What is the meaning of all of this anyway? To what end? Michael Bernard Beckwith popularized the idea of, Life Visioning. As I understand it, it is a…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Externalise application configs for your Spring Boot apps using AWS Parameter Store

If you run your Spring Boot applications on AS you might want to leverage AWS SSM Parameter Store to manage some of your application configs. This will enable you to change your application configs and restart your apps without having to change your application code and rebuilding your deployment packages.

I am going to show you how you can use the Spring Cloud AWS dependency to do so.

First add the following dependency to your pom.xml file

NB: The spring.cloud.aws.version I am using is 2.1.1.RELEASE

Secondly in your AWS account go to Systems Manager then Parameter Store and create the parameters you want to externalise for your application in the following format:

For example if my application is magic-app, running in test environment and I want to create a config for a third part service that the app connects to I will create the parameter in SSM Parameter Store like so:

Now that we have the parameter in parameter store, let’s go right ahead and tell Spring boot how its going to look and find our configs in parameter store by providing a file in the resources folder named bootstrap.yml with the following contents.

From Spring Boot you can access the configs by simply using the @Value annotation like so:

If you have a default third.party.service.url value in your application.yml file it will be overriden at runtime and will be replaced by the value from SSM Parameter Store.

And you are done.

Last thing you will need to make sure that the IAM role assigned to your EC2 or ECS tasks (depending on AWS service you use to run your Spring Boot apps in AWS) has permissions to read parameters from SSM Parameter Store.

Hope you find this useful.

Add a comment

Related posts:

How Saving The Wildlife Is Good For Humans

Did you know that an overwhelming number of species have been lost within the last four decades, due to overpopulation, deforestation, climate change, consumer culture, and animal exploitation…

1. LATAR BELAKANG

Ilmu tanaman pakan ternak adalah suatu ilmu yang mempelajari segala aspek tentang sifat tanaman ternak yang erat hubungannya dengan keadaan tanah, iklim dan tujuan peternakan. Dalam perencanaan…

Quatro Dias que Mostraram o seu Valor

Acordo com um sobressalto na casa do Kuki. Passamos a véspera envolvidos com os preparativos da caminhada, e inexplicavelmente fomos dormir muito tarde, como sempre. Deve haver algo de ritualístico…