我正在尝试通过FileIO与ParquetIO一起使用假定角色来写入S3

编程入门 行业动态 更新时间:2024-10-19 05:19:41
本文介绍了我正在尝试通过FileIO与ParquetIO一起使用假定角色来写入S3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

第1步:AssumeRole

Step1 : AssumeRole

public static AWSCredentialsProvider getCredentials() { if (roleARN.length() > 0) { STSAssumeRoleSessionCredentialsProvider credentialsProvider = new STSAssumeRoleSessionCredentialsProvider .Builder(roleARN, Constants.SESSION_NAME) .withStsClient(AWSSecurityTokenServiceClientBuilder.defaultClient()) .build(); return credentialsProvider; } return new ProfileCredentialsProvider(); }

第2步:将凭据设置为管道

Step 2 : Set Credentials to pipeline

credentials = getCredentials(); pipeline.getOptions().as(AwsOptions.class).setAwsRegion(Regions.US_WEST_2.getName()); pipeline.getOptions().as(AwsOptions.class).setAwsCredentialsProvider(new AWSStaticCredentialsProvider(new BasicAWSCredentials(credentials.getCredentials().getAWSAccessKeyId(), credentials.getCredentials().getAWSAccessKeyId())));

第3步:运行管道以写入s3

Step 3 : Run pipeline to write to s3

PCollection<GenericRecord> parquetRecord = formattedEvent .apply("ParquetRecord", ParDo.of(new ParquetWriter())) .setCoder(AvroCoder.of(getOutput_schema())); parquetRecord.apply(FileIO.<GenericRecord, GenericRecord>writeDynamic() .by(elm -> elm) .via(ParquetIO.sink(getOutput_schema())) .to(outputPath).withNumShards(1) .withNaming(type -> FileNaming.getNaming("part", ".snappy.parquet", "" + DateTime.now().getMillisOfSecond())) .withDestinationCoder(AvroCoder.of(getOutput_schema())));

我正在使用'org.apache.beam:beam-sdks-java-io-parquet:jar:2.22.0'和'org.apache.beam:beam-sdks-java-io-amazon-web-services:jar:2.22.0'

问题:当前假设角色似乎无法正常工作.

Issue : Currently assumeRole seems to be not working.

错误:

org.apache.beam.sdk.util.UserCodeException: java.lang.RuntimeException: org.apache.beam.sdk.util.UserCodeException: java.io.IOException: com.amazonaws.services.s3.model.AmazonS3Exception: The AWS Access Key Id you provided does not exist in our records.

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unexpected IOException (of type java.io.IOException): Failed to serialize and deserialize property 'awsCredentialsProvider' with value 'com.amazonaws.auth.InstanceProfileCredentialsProvider@71262020'

推荐答案

最近释放梁(2.24.0)具有承担作用的功能.

Recently release of beam (2.24.0) has the feature to assume role.

更多推荐

我正在尝试通过FileIO与ParquetIO一起使用假定角色来写入S3

本文发布于:2023-11-28 07:04:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:假定   角色   FileIO   ParquetIO

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!