[英]aws Amazon S3 client credentials in pig user defined function
I made a user defined function for my pig script to delete a folder. 我为我的猪脚本制作了一个用户定义的函数,以删除文件夹。 But how do i get the credentials?
但是我如何获得证书?
REGISTER s3://emr-custom-jars/custom.jar;
if i put register in my pig script it can access files on aws storage. 如果我在我的猪脚本中添加注册,它可以访问AWS存储上的文件。 so my credentials must be available for pig.
因此我的凭证必须可用于猪。 can i access my credentials or AmazoneS3Client without uploading my accessKey and secretKey inside my jar?
我可以在不将我的accessKey和secretKey上载到jar的情况下访问我的凭证或AmazoneS3Client吗?
private AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
private AmazonS3Client s3client = new AmazonS3Client(credentials);
@Override
public void deleteObjectsInFolder(String bucketName, String folderPath) {
for (S3ObjectSummary file : s3client.listObjects(bucketName, folderPath).getObjectSummaries()){
s3client.deleteObject(bucketName, file.getKey());
}
}
Yes, there are a couple of ways to provide the access credentials without having to hard-code the values in the jar. 是的,有两种方法可以提供访问凭据,而不必对jar中的值进行硬编码。 AmazonS3Client
AmazonS3Client
public AmazonS3Client()
Constructs a new client to invoke service methods on Amazon S3.
构造一个新客户端以在Amazon S3上调用服务方法。 A credentials provider chain will be used that searches for credentials in this order:
将使用凭证提供者链按以下顺序搜索凭证:
- Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
环境变量-AWS_ACCESS_KEY_ID和AWS_SECRET_KEY
- Java System Properties - aws.accessKeyId and aws.secretKey
Java系统属性-aws.accessKeyId和aws.secretKey
- Credential profiles file at the default location (~/.aws/credentials) shared by all AWS SDKs and the AWS CLI
所有AWS开发工具包和AWS CLI共享的凭证配置文件位于默认位置(〜/ .aws / credentials)
- Instance Profile Credentials - delivered through the Amazon EC2 metadata service
实例配置文件凭证-通过Amazon EC2元数据服务提供
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.