awspring / spring-cloud-aws

The New Home for Spring Cloud AWS
http://awspring.io
Apache License 2.0
892 stars 303 forks source link

Profile missing from SSM path when using prefix in Parameter store #655

Closed pacome2018 closed 1 year ago

pacome2018 commented 1 year ago

Type: Bug

Component: "Parameter Store"

Describe the bug

Version : io.awspring.cloud:spring-cloud-starter-aws-parameter-store-config:2.4.3

Description : While loading application properties from SSM at the lambda startup with awspring parameter store library, there is a different behaviour when using the aws.paramstore.prefix v.s. not using it. The profile is not correctly appended to the application name when the prefix is used.

I'm having trouble figuring why this is happening and how to fix it.

Sample

application.properties : spring.application.name=myProject spring.config.import=aws-parameterstore: aws.paramstore.prefix=/home/project/myProject spring.profiles.default=dev

In the lambda logs, error is caused by look up to incorrect path : ConfigDataResourceNotFoundException: Config data resource '[AwsParamStoreConfigDataResource@2bd2b28e context = '/home/project/myProject/myProject/', optional = false]' via location 'aws-parameterstore:' cannot be found

Here the prefix works but the profile is not concatenated with the application name.

when dropping the aws.paramstore.prefix=/home/project/myProject ConfigDataResourceNotFoundException: Config data resource '[AwsParamStoreConfigDataResource@2bd2b28e context = '/config/myProject_dev/', optional = false]' via location 'aws-parameterstore:' cannot be found

In the second case, the profile is correctly concatenated with the application name, but I want to use the prefix property ...

maciejwalkowiak commented 1 year ago

@MatejNedic can you take a look?

MatejNedic commented 1 year ago

@maciejwalkowiak yes will do

MatejNedic commented 1 year ago

Hey, sorry for the late reply but could you please provide a sample? In your first case it is expected to have the following locations tried:

/home/project/myProject/myProject_dev/
/home/project/myProject/myProject/
/home/project/myProject/application_dev/
/home/project/myProject/application/

I tried it running locally and I am getting the same order. Have not tried it in lambda but don't see why there should be differences.

pacome2018 commented 1 year ago

It works in local but not in lambda 🤔 I tried a fresh deployment of my lambda and the error persists.

maciejwalkowiak commented 1 year ago

@pacome2018 provide us please a sample application ideally with SAM that can be started locally that reproduces this issue.

maciejwalkowiak commented 1 year ago

Closing due to lack of feedback. Feel free to comment if there are any news and we can then consider reopening.