问题描述
我们正在使用EMR。在提交Spark作业之前,我们尝试从AWS Param Store(我们编写了Java程序)中提取配置参数,并创建一个文件并将其用于spark-submit中。
我们正在使用 aws-java-sdk-ssm API从参数存储中提取参数。
当我们尝试在主节点上运行该程序时,期望连接到aws ssm以提取参数的令牌(.aws / configure / credentials)。
我们能够在没有任何凭据的情况下访问S3存储桶,但无法访问参数存储。
我们正在从大厅管道中分解EMR集群。
private static List<Parameter> getParametersFromAWSParamStore(String path,String awsRegion){
List<Parameter> paramList = new ArrayList<>();
AWSSimpleSystemsManagement client = AWSSimpleSystemsManagementClientBuilder.standard().withRegion(awsRegion).build();
GetParametersByPathRequest request = new GetParametersByPathRequest();
request.withRecursive(true);
request.withPath(path);
request.setWithDecryption(true);
GetParametersByPathResult result = null;
do {
result = client.getParametersByPath(request);
paramList.addAll(result.getParameters());
}while( result.getNextToken() !=null && !result.getNextToken().isEmpty());
return paramList;
}
解决方法
我们需要确保执行此程序的IAM角色具有ssm:getParametersByPath策略。
之前缺少该策略,因此无法提取属性。