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

non profile SecretManager get's executed even when starting with a profile #764

Closed Frantch closed 3 years ago

Frantch commented 3 years ago

Type: Bug

Component: "Secrets Manager"

Describe the bug Not entirely sure this is a bug or I'm missing something very trivial but when starting my app with a profile the secret manager still tries to fetch a secret with the values it finds in the application.yml which makes it impossible to test the app locally.

Sample Spring Boot 2.4.2 spring-cloud-starter-aws-secrets-manager-config 2.3.0-RC2

Two property files

I just need to fetch one secret entry from AWS Secret Manager so I have defined this in the application.yml

spring.config.import: aws-secretsmanager:/secret/my-app

And I'm amending the endpoint for the dev profile (in application-dev.yml) in order to use localstack

`aws.secretsmanager.endpoint: http://127.0.0.1:4566`

When I start the app with the -Dspring.profiles.active=dev the library tries to fetch the secret first using the value in application.yml and off course fails because the endpoint will be the default aws one.

I have tried using only spring.config.import: 'aws-secretsmanager:' since the doc says it will fetch the secret for the active profile but it still tries to fetch the secret using the endpoint in the application.yml file

Why is the library still trying to load the secret using the application.yml when the app is started with the dev profile ? Is there a way to 'only' fetch the secret for the profile that is currently active ?