Spring Cloud Config Server 支持将 AWS Parameter Store 作为配置属性的后端。您可以通过向适用于 SSM 的 AWS Java 开发工具包添加依赖项来启用此功能。Spring中文文档

pom.xml
<dependency>
    <groupId>software.amazon.awssdk</groupId>
    <artifactId>ssm</artifactId>
</dependency>

以下配置使用 AWS SSM 客户端访问参数。Spring中文文档

spring:
  profiles:
    active: awsparamstore
  cloud:
    config:
      server:
        awsparamstore:
          region: eu-west-2
          endpoint: https://ssm.eu-west-2.amazonaws.com
          origin: aws:parameter:
          prefix: /config/service
          profile-separator: _
          recursive: true
          decrypt-values: true
          max-results: 5

下表介绍了 AWS Parameter Store 配置属性。Spring中文文档

表 1.AWS Parameter Store 配置属性
物业名称 必填 默认值 言论

地区Spring中文文档

Spring中文文档

AWS Parameter Store 客户端要使用的区域。如果未显式设置,SDK 将尝试使用默认区域提供程序链确定要使用的区域。Spring中文文档

端点Spring中文文档

Spring中文文档

AWS SSM 客户端的入口点的 URL。这可用于为 API 请求指定备用终结点。Spring中文文档

起源Spring中文文档

Spring中文文档

aws:ssm:parameter:Spring中文文档

添加到属性源名称以显示其来源的前缀。Spring中文文档

前缀Spring中文文档

Spring中文文档

/configSpring中文文档

前缀,指示从 AWS Parameter Store 加载的每个属性的参数层次结构中的 L1 级别。Spring中文文档

轮廓分离器Spring中文文档

Spring中文文档

-Spring中文文档

将追加的配置文件与上下文名称分隔开来的字符串。Spring中文文档

递归的Spring中文文档

Spring中文文档

trueSpring中文文档

标志指示在层次结构中检索所有 AWS 参数。Spring中文文档

解密值Spring中文文档

Spring中文文档

trueSpring中文文档

标志以指示检索所有 AWS 参数及其值已解密。Spring中文文档

最大结果Spring中文文档

Spring中文文档

10Spring中文文档

AWS Parameter Store API 调用要返回的最大项目数。Spring中文文档

AWS Parameter Store API 凭证是使用默认凭证提供程序链确定的。 已支持版本控制参数,默认行为是返回最新版本。Spring中文文档

  • 默认情况下未指定应用程序,未指定配置文件时使用配置文件。applicationdefaultSpring中文文档

  • 的有效值必须以正斜杠开头,后跟一个或多个有效路径段,否则为空。awsparamstore.prefixSpring中文文档

  • 的有效值只能包含点、破折号和下划线。awsparamstore.profile-separatorSpring中文文档

  • 的有效值必须在 [1, 10] 范围内。awsparamstore.max-resultsSpring中文文档

  • 默认情况下未指定应用程序,未指定配置文件时使用配置文件。applicationdefaultSpring中文文档

  • 的有效值必须以正斜杠开头,后跟一个或多个有效路径段,否则为空。awsparamstore.prefixSpring中文文档

  • 的有效值只能包含点、破折号和下划线。awsparamstore.profile-separatorSpring中文文档

  • 的有效值必须在 [1, 10] 范围内。awsparamstore.max-resultsSpring中文文档