1

Spring Boot newbie here. I am trying to read credentials from AWS Parameter Store. To do that, I have added the following dependencies to pom.xml:

    <dependency>
        <groupId>io.awspring.cloud</groupId>
        <artifactId>spring-cloud-starter-aws</artifactId>
        <version>2.4.2</version>
    </dependency>
    <dependency>
        <groupId>io.awspring.cloud</groupId>
        <artifactId>spring-cloud-aws-parameter-store-config</artifactId>
        <version>2.4.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bootstrap</artifactId>
        <version>3.1.4</version>
    </dependency>

I am using Spring Boot version version 2.7.4. When I run the application, it fails to boot and prints the following error:

Caused by: java.lang.IllegalStateException: Unable to load config data from 'aws-parameterstore:'

How do I read credentials from AWS parameter store?

Update

There is a parameter stored at the path /config/myap_dev/dummy. I have added the following config to my bootstrap.properties:

spring.application.name=myapp
aws.paramstore.defaultContext=application
aws.paramstore.profileSeparator=_
aws.paramstore.prefix=/config
aws.paramstore.enabled=true

and in my application-dev.yaml I do the following to retrieve the parameter:

spring.config.import: "aws-parameterstore:"
param: "${dummy}"

I am running the application using mvn spring-boot:run.

4
  • This doesn't show how your are fetching the aws-parameterstore? How do you run it? etc... Commented Oct 20, 2022 at 12:18
  • @grekier I updated my question to include more details. Please let me know if I should add something more. Commented Oct 21, 2022 at 4:39
  • How do you have access to AWS defined? Do you have env variable for AWS_ACCESS_KEY_ID, AWS_REGION, and AWS_SECRET_ACCESS_KEY or something else? I also think you need to set AWS_EC2_METADATA_DISABLED=true and cloud.aws.stack.auto=false when not running in AWS Commented Oct 21, 2022 at 7:09
  • @grekier It's running locally with AWS_ACCESS_KEY_ID, AWS_REGION, and AWS_SECRET_ACCESS_KEY defined as environment variables. I added cloud.aws.stack.auto: false but the error still persists. Commented Oct 21, 2022 at 7:41

2 Answers 2

0

If you're running in AWS then ensure that the service you're using (e.g. an ECS task) has permission to access the parameter store. See section 3.3 here https://docs.awspring.io/spring-cloud-aws/docs/current/reference/html/index.html

Sign up to request clarification or add additional context in comments.

Comments

0

You have an incorrect dependency in your pom:

spring-cloud-aws-parameter-store-config

...should be...

spring-cloud-starter-aws-parameter-store-config

Hope it helps, took quite a lot to figure out and probably package names could be confusing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.