This repository was archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 369
Cannot add several AwsSecretsManagerPropertySourceLocator in a project #472
Labels
component: secrets-manager
Secrets Manager integration related issue
status: waiting-for-triage
An issue we've not yet triaged
Comments
@anthofo thanks for reporting an issue and PR. Since it stays backward compatible we can merge it now to branch 2.2.x but i am wondering if it would make sense to support an example you provided out of the box:
|
tmnuwan12
pushed a commit
to tmnuwan12/spring-cloud-aws
that referenced
this issue
Jun 7, 2020
…pertySourceLocator. Fixes spring-atticgh-472 Closes spring-atticgh-473
maciejwalkowiak
pushed a commit
to maciejwalkowiak/spring-cloud-aws
that referenced
this issue
Oct 15, 2020
…pertySourceLocator. Fixes spring-atticgh-472 Closes spring-atticgh-473
maciejwalkowiak
pushed a commit
to maciejwalkowiak/spring-cloud-aws
that referenced
this issue
Oct 15, 2020
…pertySourceLocator. Fixes spring-atticgh-472 Closes spring-atticgh-473
maciejwalkowiak
pushed a commit
to maciejwalkowiak/spring-cloud-aws
that referenced
this issue
Oct 15, 2020
…pertySourceLocator. Fixes spring-attic#472 Closes spring-attic#473
maciejwalkowiak
pushed a commit
to maciejwalkowiak/spring-cloud-aws
that referenced
this issue
Oct 15, 2020
…pertySourceLocator. Fixes spring-attic#472 Closes spring-attic#473
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
component: secrets-manager
Secrets Manager integration related issue
status: waiting-for-triage
An issue we've not yet triaged
Enhancement
Suppose you have several AWS Secrets you want to add in your application. I did it the same way for having multiple datasources in Spring Boot.
These 2 AWS Secrets are for instance:
They are separated because some apps might want the salesforce credentials, without the rds which is specific to each app. To do so I modified the bootstrap.yml to add a new level which is the name of the secret source:
Of course the
AwsSecretsManagerBootstrapConfiguration
would crash with this because it doesn't match the expectedAwsSecretsManagerProperties
.So I overloaded the beans this way in an
@Configuration
class:Creating 2 PropertySourceLocator beans should work because
PropertySourceBootstrapConfiguration
creates a compositeCompositePropertySource
from all thePropertySourceLocator
it finds.But it doesn't work, for a very simple reason: in
CompositePropertySource
the sources are stored in a Set. The hashCode of aPropertySource
is the hash of its name.Which leads to the issue: in
AwsSecretsManagerPropertySourceLocator.locate()
theCompositePropertySource
name is always set to "aws-secrets-manager". If you create 2AwsSecretsManagerPropertySourceLocator
they will have the same name, and then the same hashCode that will be considered as a duplicate in the Set ofCompositePropertySource
.The solution is easy and straightforward: allow to set the
PropertySourceLocator
name in the constructor so you can have 2 different names (first constructor property):Problem solved !
The text was updated successfully, but these errors were encountered: