spring-attic / spring-cloud-aws

All development has moved to https://github.com/awspring/spring-cloud-aws Integration for Amazon Web Services APIs with Spring
https://awspring.io/
Apache License 2.0
589 stars 376 forks source link

AWS Parameter Store with Hoxton SR8+ doesn't override properties when using multiple profiles #772

Open peteguyatt opened 3 years ago

peteguyatt commented 3 years ago

Type: Bug

Component:

Parameter Store

Describe the bug When using multiple active profiles with spring cloud Hoxton SR10 and boot 2.3.9 we have noticed that property order seems to have changed, for example if we have two properties set E.g.

spring.profiles.active=profile_a,profile_b

Parameter Store configured as:

application/profile_a/app.secret-key: abc-123
application/profile_b/app.secret-key: efd-213

and in our bean we have

@Value("${app.secret-key}")
private String secretKey; 

the value resolved will be abc-123 instead of efd-213

I looked through the commit history for AwsParamStorePropertySourceLocator and the issue seems to have been introduced in https://github.com/spring-cloud/spring-cloud-aws/commit/582fdc6691ead7904aaed176af2cf85221edacd5 where the Collections.reverse has been removed due to switching to using a LinkedHashSet

This looks like an accidental bug to me and the same bug exists in master and the 2.3.x branch

maciejwalkowiak commented 2 years ago

@MatejNedic can you take a look at this one? We should fix it in both 2.2.x in this repo and 2.3.x in awspring. This PR too.

WtfJoke commented 2 years ago

I think I experience the same issue with both (secretsmanager and the parameter store).

In my case the least specific one always wins (eg. /config/application over /config/application_profile and both over /config/service)

Do you need a sample project? I might can extend the sample project. Or can I help in some other way to solve this issue? Should I test the PR?

EDIT: Woops, I thought I was in the new repo, there is an issue already open --> https://github.com/awspring/spring-cloud-aws/issues/169

peteguyatt commented 2 years ago

@WtfJoke You're correct the same issue exists with secrets manager too @maciejwalkowiak & @MatejNedic any chance of getting this merged in?

peteguyatt commented 2 years ago

I'm happy to create a separate PR for the secrets manager fix too if there is a appetite for this

WtfJoke commented 2 years ago

@peteguyatt the PR https://github.com/awspring/spring-cloud-aws/pull/195 contains fixes for both (secrets manager and parameter store).

Its probably better if we discuss in the new (migrated) issue 👍

peteguyatt commented 2 years ago

@WtfJoke Thanks for porting the fix to the new repo and fixing secrets manager while you were at it, would you mind adding me as a contributor to the unit tests/PR in general?