2014-05-04 33 views
2

我試圖使用AWS Java SDK v1.7.5訪問我的AWS DataPipelines,但listPipelines正在返回下面代碼中的空列表。AWS DataPipelineClient - listPipelines不返回記錄

我有美國東部地區的DataPipelines計劃,我相信我應該能夠使用DataPipelineClient的listPipelines方法列出。我已經在使用ProfilesConfigFile進行身份驗證並連接到S3,DynamoDB和Kinesis,沒有任何問題。我已將PowerUserAccess訪問策略授予配置文件中指定的IAM用戶。我也嘗試將管理員訪問策略應用於用戶,但沒有改變任何內容。下面是我使用的代碼:

//Establish credentials for connecting to AWS. 
File configFile = new File(System.getProperty("user.home"), ".aws/config");  
ProfilesConfigFile profilesConfigFile = new ProfilesConfigFile(configFile);    
AWSCredentialsProvider awsCredentialsProvider = new ProfileCredentialsProvider(profilesConfigFile, "default"); 

//Set up the AWS DataPipeline connection. 
DataPipelineClient dataPipelineClient = new DataPipelineClient(awsCredentialsProvider); 
Region usEast1 = Region.getRegion(Regions.US_EAST_1); 
dataPipelineClient.setRegion(usEast1); 

//List all pipelines we have access to. 
ListPipelinesResult listPipelinesResult = dataPipelineClient.listPipelines(); //empty list returned here. 
for (PipelineIdName p: listPipelinesResult.getPipelineIdList()) { 
    System.out.println(p.getId()); 
} 

回答

0

請一定要檢查是否有更多的結果 - 我有時發現API返回只有少數管線(甚至可以是空的),但更多的結果的標誌。你可以像這樣找回它們:

void listPipelines(DataPipelineClient dataPipelineClient, String marker) { 
    ListPipelinesRequest request = new ListPipelinesRequest(); 
    if (marker != null) { 
     request.setMarker(marker); 
    } 

    ListPipelinesResult listPipelinesResult = client.listPipelines(request); 
    for (PipelineIdName p: listPipelinesResult.getPipelineIdList()) { 
     System.out.println(p.getId()); 
    } 

    // Call recursively if there are more results: 
    if (pipelineList.getHasMoreResults()) { 
     listPipelines(dataPipelineClient, listPipelinesResult.getMarker()); 
    } 
}