gpt4 book ai didi

java - AWSSimpleSystemsManagement describeParameters 一次仅返回一个参数

转载 作者:太空宇宙 更新时间:2023-11-04 10:09:46 26 4
gpt4 key购买 nike

我正在尝试从 AWS 获取以特定前缀开头的参数列表。我不知道如何获取所有参数。

ParametersFilter filter = 
new ParametersFilter().
withKey("Name").
withValues("vyom"); // the key prefix i want

DescribeParametersRequest request =
new DescribeParametersRequest().withFilters(filter);

AWSSimpleSystemsManagement client =
AWSSimpleSystemsManagementClientBuilder.defaultClient();

DescribeParametersResult result =
client.
describeParameters(request);

List<ParameterMetadata> params =
result.
getParameters(); // returns a list of size one

DescribeParametersResult 始终设置 nextToken,并再次调用客户端,使用下一个 token 返回下一个参数。

从终端调用 aws cli 将返回我预期的所有参数。aws ssm 描述参数 --filters "Key=Name,Values=vyom"

最佳答案

我也遇到了同样的问题;它似乎按设计工作。来自 docs :

Request results are returned on a best-effort basis. If you specify MaxResults in the request, the response includes information up to the limit specified. The number of items returned, however, can be between zero and the value of MaxResults. If the service reaches an internal limit while processing the results, it stops the operation and returns the matching values up to that point and a NextToken. You can specify the NextToken in a subsequent call to get the next set of results.

也就是说:过滤分页之后应用。如果我将 MaxResults 设置为 50,那么第一页将返回控制台 UI 中可见的前 50 个参数的筛选结果,第二页将返回后 50 个参数的结果,依此类推...CLI 只会为您完成遍历页面的工作。

一旦开始对结果进行分页,您将遇到的下一个问题是激进的限制。有一些很好的讨论here ,包括 gem :

Obviously the best solution would be to increase the AWS rate-limits, but they seem very unwilling to do that for DescribeParameters (they insist that it should only be used for manual querying on a CLI).

祝你好运!

关于java - AWSSimpleSystemsManagement describeParameters 一次仅返回一个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52501944/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com