<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Authentication for Amazon s3 using Temporary credentials (STS) in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Authentication-for-Amazon-s3-using-Temporary-credentials-STS/m-p/62593#M22580</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;We are currently running some tests regarding the authentication for amazon s3 using temporary credentials and encountering the following errors.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We wanted to test this snippet : &lt;A href="https://github.com/satishpandey/aws-spark-samples/blob/master/src/com/spark/aws/samples/s3/SparkS3STSAssumeRole.java" target="_blank"&gt;https://github.com/satishpandey/aws-spark-samples/blob/master/src/com/spark/aws/samples/s3/SparkS3STSAssumeRole.java&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;in a cloudera 5.13 cluster with Spark 2.2.&lt;BR /&gt;We just changed a bit the code to use "BasicAWSCredentials" instead of "InstanceProfileCredentialsProvider".&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;...&lt;BR /&gt;Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.SDKGlobalConfiguration.isInRegionOptimizedModeEnabled()Z&lt;BR /&gt;at com.amazonaws.ClientConfigurationFactory.getConfig(ClientConfigurationFactory.java:35)&lt;BR /&gt;at com.amazonaws.client.builder.AwsClientBuilder.resolveClientConfiguration(AwsClientBuilder.java:163)&lt;BR /&gt;at com.amazonaws.client.builder.AwsClientBuilder.access$000(AwsClientBuilder.java:52)&lt;BR /&gt;at com.amazonaws.client.builder.AwsClientBuilder$SyncBuilderParams.&amp;lt;init&amp;gt;(AwsClientBuilder.java:411)&lt;BR /&gt;at com.amazonaws.client.builder.AwsClientBuilder.getSyncClientParams(AwsClientBuilder.java:354)&lt;BR /&gt;at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)&lt;BR /&gt;at com.spark.aws.samples.s3.SparkS3STSAssumeRole.main(SparkS3STSAssumeRole.java:57)&lt;BR /&gt;at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;BR /&gt;at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)&lt;BR /&gt;at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&lt;BR /&gt;at java.lang.reflect.Method.invoke(Method.java:606)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The issue is comming from the jar "aws-java-sdk.1.10.6" which is comming from the cluster and used instead of the version "1.11.145" provided in the pom.xml (which contained the method).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We tried to follow the cloudera documentation : &lt;A href="https://www.cloudera.com/documentation/enterprise/latest/topics/sg_aws_credentials.html" target="_blank"&gt;https://www.cloudera.com/documentation/enterprise/latest/topics/sg_aws_credentials.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;To set some hadoop properties :&lt;BR /&gt;-Dfs.s3a.access.key=your_temp_access_key&lt;BR /&gt;-Dfs.s3a.secret.key=your_temp_secret_key&lt;BR /&gt;-Dfs.s3a.session.token=your_session_token_from_AmazonSTS&lt;BR /&gt;-Dfs.s3a.aws.credentials.provider=org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;But in that case, we had that issue :&lt;BR /&gt;...&lt;BR /&gt;Exception in thread "main" java.lang.IllegalArgumentException: AWS Access Key ID and Secret Access Key must be specified by setting the fs.s3n.awsAccessKeyId and fs.s3n.awsSecretAccessKey properties (respectively).&lt;BR /&gt;at org.apache.hadoop.fs.s3.S3Credentials.initialize(S3Credentials.java:74)&lt;BR /&gt;at org.apache.hadoop.fs.s3native.Jets3tNativeFileSystemStore.initialize(Jets3tNativeFileSystemStore.java:80)&lt;BR /&gt;at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;BR /&gt;at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)&lt;BR /&gt;at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&lt;BR /&gt;at java.lang.reflect.Method.invoke(Method.java:606)&lt;BR /&gt;at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:256)&lt;BR /&gt;at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:104)&lt;BR /&gt;at org.apache.hadoop.fs.s3native.$Proxy36.initialize(Unknown Source)&lt;BR /&gt;at org.apache.hadoop.fs.s3native.NativeS3FileSystem.initialize(NativeS3FileSystem.java:334)&lt;BR /&gt;at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2800)&lt;BR /&gt;at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:98)&lt;BR /&gt;at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2837)&lt;BR /&gt;at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2819)&lt;BR /&gt;at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:387)&lt;BR /&gt;at org.apache.hadoop.fs.Path.getFileSystem(Path.java:296)&lt;BR /&gt;at org.apache.hadoop.mapreduce.security.TokenCache.obtainTokensForNamenodesInternal(TokenCache.java:97)&lt;BR /&gt;at org.apache.hadoop.mapreduce.security.TokenCache.obtainTokensForNamenodes(TokenCache.java:80)&lt;BR /&gt;at org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:206)&lt;BR /&gt;at org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:315)&lt;BR /&gt;at org.apache.spark.rdd.HadoopRDD.getPartitions(HadoopRDD.scala:202)&lt;BR /&gt;at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:252)&lt;BR /&gt;at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:250)&lt;BR /&gt;at scala.Option.getOrElse(Option.scala:121)&lt;BR /&gt;at org.apache.spark.rdd.RDD.partitions(RDD.scala:250)&lt;BR /&gt;at org.apache.spark.rdd.MapPartitionsRDD.getPartitions(MapPartitionsRDD.scala:35)&lt;BR /&gt;at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:252)&lt;BR /&gt;at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:250)&lt;BR /&gt;at scala.Option.getOrElse(Option.scala:121)&lt;BR /&gt;at org.apache.spark.rdd.RDD.partitions(RDD.scala:250)&lt;BR /&gt;at org.apache.spark.SparkContext.runJob(SparkContext.scala:1958)&lt;BR /&gt;at org.apache.spark.rdd.RDD.count(RDD.scala:1157)&lt;BR /&gt;at org.apache.spark.api.java.JavaRDDLike$class.count(JavaRDDLike.scala:455)&lt;BR /&gt;at org.apache.spark.api.java.AbstractJavaRDDLike.count(JavaRDDLike.scala:45)&lt;BR /&gt;at com.spark.aws.samples.s3.SparkS3STSAssumeRole.main(SparkS3STSAssumeRole.java:64)&lt;BR /&gt;at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)&lt;BR /&gt;at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)&lt;BR /&gt;at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)&lt;BR /&gt;at java.lang.reflect.Method.invoke(Method.java:606)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:738)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)&lt;BR /&gt;at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We generated the token and temporary access / secret key with this java code :&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;...&lt;BR /&gt;com.amazonaws.auth.AWSCredentials credentials = new com.amazonaws.auth.BasicAWSCredentials("XXX","XXX");&lt;BR /&gt;com.amazonaws.auth.AWSCredentialsProvider credentialsProvider = new com.amazonaws.internal.StaticCredentialsProvider(credentials);&lt;BR /&gt;&lt;BR /&gt;com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration endp = new com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration("sts.eu-west-1.amazonaws.com","eu-west-1");&lt;BR /&gt;com.amazonaws.services.securitytoken.AWSSecurityTokenService sts = com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder.standard().withCredentials(credentialsProvider).withEndpointConfiguration(endp).build();&lt;BR /&gt;com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider provider2 = new com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider.Builder("myArnRole", "testSessionName").withStsClient(sts).build();&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any information/feedback will be much appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Stéfan Le Moing&lt;/P&gt;</description>
    <pubDate>Fri, 16 Sep 2022 12:37:07 GMT</pubDate>
    <dc:creator>slemoing</dc:creator>
    <dc:date>2022-09-16T12:37:07Z</dc:date>
  </channel>
</rss>

