【发布时间】:2022-01-19 07:58:46
【问题描述】:
我使用Credentials for other database 选项将我的 MySQL 数据库凭证存储在 AWS 机密管理器中。我想在我的application.properties 文件中导入这些凭据。根据我在这个线程“https://stackoverflow.com/questions/56194579/how-to-integrate-aws-secret-manager-with-spring-boot-application”中找到的一些答案,我做了以下事情:
- 添加了依赖
spring-cloud-starter-aws-secrets-manager-config - 在
application.properties中添加了spring.application.name = <application name>和spring.config.import = aws-secretsmanager: <Secret name> - 在以下属性中使用密钥作为占位符:
spring.datasource.url = jdbc:mysql://${host}:3306/db_name spring.datasource.username=${username} spring.datasource.password=${password}
运行应用程序时出现以下错误:
java.lang.IllegalStateException: Unable to load config data from 'aws-secretsmanager:<secret_name>'
Caused by: java.lang.IllegalStateException: File extension is not known to any PropertySourceLoader. If the location is meant to reference a directory, it must end in '/' or File.separator
首先,我遵循的流程是否正确?如果是,这个错误是什么以及如何解决这个问题?
【问题讨论】:
-
您是否在
spring.config.import中指定了所有秘密?如果没有,并且如果您想通过您的应用程序名称来解决它们,请尝试使用spring.config.import=aws-secretsmanager:(参见说明here) -
我在一个秘密
/secret/<app_name>_<profile>/credentials中拥有我想要的所有密钥。我正在使用spring.config.import=aws-secretsmanager:/secret/<app_name>_<profile>/credentials。
标签: amazon-web-services spring-boot spring-cloud spring-cloud-config aws-secrets-manager