Bug(enhancement?)
Spring cloud AWS v. 2.1.1-RELEASE
My organization settled on a secrets manager name convention that is non-conformant to Spring's secrets manager naming strategy. it currently forces a Secret Name similar to dev-MyServiceName. It does not appear to be possible to configure Spring Cloud AWS secret manager to not use a / as a separator, thus making my key impossible to retrieve using spring cloud Aws secret manager. I recognize that this naming convention is non-optimal, but my efforts at affecting changer have not been successful.
I believe the issue lies in/around line 82 of AwsSecretsManagerPropertySourceLocator and again near line 86 of the same file.
If this separator was parameterized as an env property option, I believe this would solve the issue.
I have the exact same issue.
AWS secrets manager is not hierarchical, but the AwsSecretsManagerPropertySourceLocator has an hardcoded / separator at lines 82 and 86.
For instance, my app secrets are stored in an aws secret named like my-app-dev. This secret stores a list of key:value.
I specified an empty prefix in the configuration file bootstrap.yml, but because the line 86 has an hardcoded /, this class tries to find a secret named /my-app-dev, and fails because the secret is named my-app-devwith no leading /
Your issue is exactly the same as what I was seeing.
My workaround for right now is to implement a secrets post processor by implementing EnvironmentPostProcessor, and then use the AWS client lib to call getSecretValue with my specific, non-compliant key. At some point I will probably add the key name to a profile variable in the bootstrap.yml so it can be changed based on invocation profile settings.
But it would be REALLY nice to not have to do all that.
As a side note, I also happened to ask a question about this on stackoverflow here
I pushed a a PR to fix this issue.
My workaround for now:
spring-cloud-starter-aws-secrets-manager-config dependency and replace it by spring-cloud-aws-secrets-manager-configAwsSecretsManagerBootstrapConfiguration from spring-cloud-starter-aws-secrets-manager-config and AwsSecretsManagerPropertySourceLocator from spring-cloud-aws-secrets-manager-config into your projectAwsSecretsManagerBootstrapConfiguration change the AwsSecretsManagerPropertySourceLocator import with the path of your own copyAwsSecretsManagerPropertySourceLocator copyMETA-INF that contains a file spring.factories with the following content:org.springframework.cloud.bootstrap.BootstrapConfiguration=\
fr.anthofo.utils.AwsSecretsManagerBootstrapConfiguration
(replace fr.anthofo.utils with the path of your own AwsSecretsManagerBootstrapConfiguration copy)
@anthofo @sanimalp is this PR approved, I don't see your changes reflect in the master.
Can you please help me identifying correct version where these changes are merged
These changes have not been merged, i am sorry to say. It is unclear why, but may be related to the failing travisCI build related to the branch.
Thank you for your reply. I really wonder why this is not merged. This is very basic and essential change required.
For the same reason I am unable to use the aws secret manager starter.
Lets continue discussion in #554
Most helpful comment
I pushed a a PR to fix this issue.
My workaround for now:
spring-cloud-starter-aws-secrets-manager-configdependency and replace it byspring-cloud-aws-secrets-manager-configAwsSecretsManagerBootstrapConfigurationfromspring-cloud-starter-aws-secrets-manager-configandAwsSecretsManagerPropertySourceLocatorfromspring-cloud-aws-secrets-manager-configinto your projectAwsSecretsManagerBootstrapConfigurationchange theAwsSecretsManagerPropertySourceLocatorimport with the path of your own copyAwsSecretsManagerPropertySourceLocatorcopyMETA-INFthat contains a filespring.factorieswith the following content:(replace
fr.anthofo.utilswith the path of your ownAwsSecretsManagerBootstrapConfigurationcopy)