AWS SSM parameter store not fetching all key/values

后端 未结 3 502
萌比男神i
萌比男神i 2021-01-21 00:07

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

   GetParametersByPathRequest getParametersByPathRequest = new          


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 00:49

     private void getSsmParams() {
    
        AWSSimpleSystemsManagement client = AWSSimpleSystemsManagementClientBuilder.defaultClient();
        GetParametersByPathRequest request = new GetParametersByPathRequest();
        request.withRecursive(true);
        request.withPath('/your/path/parameterName').setWithDecryption(true);
    
        GetParametersByPathResult response;
    
        do {
    
          response = client.getParametersByPath(request);
    
          for (Parameter p : response.parameters()) {
            //do something with the values. maybe add to a list
          }
    
          request.setNextToken(response.getNextToken())
        }
    
        while (StringUtils.isNotBlank(response.getNextToken()));
    
      }
    

    Above piece of code worked for me .ssm only sends 10 parameters at a time, so if you want to fetch more than 10 parameters from ssm parameter store programatically you will have to use multiple calls to fetch them. here the token is important , if there are more values in the path (request.withPath('/your/path/parameterName')) you have given, it will send a token indicating that there are more values in the given path ,and you will have to make the following request with the token received from the previous request in order to get the rest of the values.

提交回复
热议问题