简体   繁体   中英

Unable to connect to AWS SSM parameter using Spring boot

I want my spring boot application to connect AWS SSM parameter (Spring Boot Properties to an AWS System Manager Parameter Store)

While am starting my spring boot app, it throws the following error

org.springframework.boot.context.config.ConfigDataResourceNotFoundException: Config data resource '[AwsParamStoreConfigDataResource@34e20e6b context = '/config/application/', optional = false]' via location 'aws-parameterstore:' cannot be found
    at org.springframework.boot.context.config.ConfigDataResourceNotFoundException.withLocation(ConfigDataResourceNotFoundException.java:97)
    at org.springframework.boot.context.config.ConfigDataImporter.handle(ConfigDataImporter.java:145)
    at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:136)
    at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
    at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processWithProfiles(ConfigDataEnvironment.java:311)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:232)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:374)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:332)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
    at com.rnd.aws.AwsApplication.main(AwsApplication.java:10)
Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
    at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:462)
    at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:424)
    at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreBootstrapConfiguration.createSimpleSystemManagementClient(AwsParamStoreBootstrapConfiguration.java:82)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreConfigDataLocationResolver.createSimpleSystemManagementClient(AwsParamStoreConfigDataLocationResolver.java:124)
    at org.springframework.boot.DefaultBootstrapContext.getInstance(DefaultBootstrapContext.java:119)
    at org.springframework.boot.DefaultBootstrapContext.getOrElseThrow(DefaultBootstrapContext.java:111)
    at org.springframework.boot.DefaultBootstrapContext.get(DefaultBootstrapContext.java:88)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreConfigDataLoader.load(AwsParamStoreConfigDataLoader.java:38)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreConfigDataLoader.load(AwsParamStoreConfigDataLoader.java:33)
    at org.springframework.boot.context.config.ConfigDataLoaders.load(ConfigDataLoaders.java:107)
    at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:128)
    ... 23 common frames omitted
11:52:05.333 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - 

APPLICATION FAILED TO START


Description:

Config data resource '[AwsParamStoreConfigDataResource@34e20e6b context = '/config/application/', optional = false]' via location 'aws-parameterstore:' does not exist

Action:

Check that the value 'aws-parameterstore:' at class path resource [application.properties] - 5:22 is correct, or prefix it with 'optional:'

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Please help me

Add this properties to your bootstrap.yml

spring:
  application:
    name: fahim
  profiles:
    active: local

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM