此版本仍在开发中,目前尚不稳定。如需最新稳定版本,请使用 Spring Cloud Config 5.0.1spring-doc.cadn.net.cn

AWS 参数存储后端

Spring Cloud Config Server 支持 AWS Parameter Store 作为配置属性的后端。您可以通过添加对 AWS Java SDK for SSM 的依赖来启用此功能。spring-doc.cadn.net.cn

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

以下配置使用 AWS SSM 客户端访问参数。spring-doc.cadn.net.cn

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 参数存储配置属性。spring-doc.cadn.net.cn

<h2>AWS Parameter Store Configuration Properties</h2> <table> <thead> <tr> <th>Property Name</th> <th>Description</th> <th>Default Value</th> </tr> </thead> <tbody> <tr> <td>aws.parameter-store.enabled</td> <td>Whether to use AWS Parameter Store for configuration.</td> <td>false</td> </tr> <tr> <td>aws.parameter-store.path</td> <td>The path in AWS Parameter Store where the configuration is stored.</td> <td>/${spring.application.name}</td> </tr> <tr> <td>aws.parameter-store.refresh-period</td> <td>The period between refreshes of the configuration from AWS Parameter Store, in seconds.</td> <td>60</td> </tr> </tbody> </table>
属性名称 必填 默认值 备注

区域spring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

AWS 参数存储客户端将使用的区域。如果未显式设置,则 SDK 尝试通过使用 默认区域提供程序链 来确定应使用的区域。spring-doc.cadn.net.cn

端点spring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

AWS SSM 客户端入口点的 URL。此 URL 可用于为 API 请求指定替代端点。spring-doc.cadn.net.cn

originspring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

aws:ssm:parameter:spring-doc.cadn.net.cn

用于添加到属性源名称前缀,以表明其来源。spring-doc.cadn.net.cn

前缀spring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

/configspring-doc.cadn.net.cn

指示从 AWS Parameter Store 加载的每个属性在参数层次结构中的 L1 级别前缀。spring-doc.cadn.net.cn

profile-separatorspring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

-spring-doc.cadn.net.cn

用于分隔附加配置文件与上下文名称的字符串。spring-doc.cadn.net.cn

recursivespring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

truespring-doc.cadn.net.cn

标志,用于指示在层次结构中检索所有 AWS 参数。spring-doc.cadn.net.cn

decrypt-valuesspring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

truespring-doc.cadn.net.cn

标志,用于指示检索所有 AWS 参数及其已解密的值。spring-doc.cadn.net.cn

max-resultsspring-doc.cadn.net.cn

nospring-doc.cadn.net.cn

10spring-doc.cadn.net.cn

AWS 参数存储 API 调用中要返回的最大项目数量。spring-doc.cadn.net.cn

AWS Parameter Store API 凭据是通过 默认凭证提供程序链 确定的。版本化参数已通过默认行为(返回最新版本)得到支持。spring-doc.cadn.net.cn

  • 当未指定应用程序时,application 是默认值;当未指定配置文件时,使用 defaultspring-doc.cadn.net.cn

  • awsparamstore.prefix 的有效取值必须以正斜杠(/)开头,后跟一个或多个有效的路径段,或者为空。spring-doc.cadn.net.cn

  • awsparamstore.profile-separator 的有效取值只能包含点、连字符和下划线。spring-doc.cadn.net.cn

  • awsparamstore.max-results 的有效范围必须在 [1, 10] 区间内。spring-doc.cadn.net.cn