AWS SSM参数存储未获取所有键/值 [英] AWS SSM parameter store not fetching all key/values

查看:90
本文介绍了AWS SSM参数存储未获取所有键/值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以让我知道为什么下面的代码只从参数存储中获取一些条目吗?

Could someone let me know why the below code only fetching few entries from the parameter store ?

   GetParametersByPathRequest getParametersByPathRequest = new GetParametersByPathRequest();
      getParametersByPathRequest.withPath("/").setRecursive(true);
      getParametersByPathRequest.setWithDecryption(true);
   GetParametersByPathResult result = client.getParametersByPath(getParametersByPathRequest);

   result.getParameters().forEach(parameter -> {
        System.out.println(parameter.getName() + " - > " + parameter.getValue());
    });

推荐答案

GetParametersByPath is a paged operation. After each call you must retrieve NextToken from the result object, and if it's not null and not empty you must make another call with it added to the request.

下面是使用DescribeParameters的示例,它具有相同的行为:

Here's an example using DescribeParameters, which has the same behavior:

DescribeParametersRequest request = new DescribeParametersRequest();
DescribeParametersResult response;
do
{
    response = client.describeParameters(request);
    for (ParameterMetadata param : response.getParameters())
    {
        // do something with metadata
    }
    request.setNextToken(response.getNextToken());
}
while ((response.getNextToken() != null) && ! respose.getNextToken.isEmpty());

这篇关于AWS SSM参数存储未获取所有键/值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆