{"action":"created","issue":{"url":"https://api.github.com/repos/databricks/spark-redshift/issues/276","repository_url":"https://api.github.com/repos/databricks/spark-redshift","labels_url":"https://api.github.com/repos/databricks/spark-redshift/issues/276/labels{/name}","comments_url":"https://api.github.com/repos/databricks/spark-redshift/issues/276/comments","events_url":"https://api.github.com/repos/databricks/spark-redshift/issues/276/events","html_url":"https://github.com/databricks/spark-redshift/issues/276","id":179913961,"number":276,"title":"AWS Keys in hadoop conf required when using IAM instance profiles.","user":{"login":"a-morales","id":4392732,"avatar_url":"https://avatars.githubusercontent.com/u/4392732?v=3","gravatar_id":"","url":"https://api.github.com/users/a-morales","html_url":"https://github.com/a-morales","followers_url":"https://api.github.com/users/a-morales/followers","following_url":"https://api.github.com/users/a-morales/following{/other_user}","gists_url":"https://api.github.com/users/a-morales/gists{/gist_id}","starred_url":"https://api.github.com/users/a-morales/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/a-morales/subscriptions","organizations_url":"https://api.github.com/users/a-morales/orgs","repos_url":"https://api.github.com/users/a-morales/repos","events_url":"https://api.github.com/users/a-morales/events{/privacy}","received_events_url":"https://api.github.com/users/a-morales/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-28T23:08:43Z","updated_at":"2016-10-18T21:59:04Z","closed_at":"2016-10-18T21:59:04Z","body":"So I've been trying to set up an EMR cluster with this library and been encountering issues along the way. I'm able to get this to run locally with no issues, but once I deploy to EMR I get issues. I first tried setting the keys in the hadoop configuration via\r\n\r\n```scala\r\n  val credentials = new DefaultAWSCredentialsProviderChain().getCredentials\r\n  sc.hadoopConfiguration.set(\"fs.s3n.awsAccessKeyId\", credentials.getAWSAccessKeyId)\r\n  sc.hadoopConfiguration.set(\"fs.s3n.awsSecretAccessKey\", credentials.getAWSSecretKey)\r\n```\r\n\r\nThis works locally, but on emr I was getting the following error:\r\n\r\n```\r\n16/09/27 23:32:41 WARN Utils$: An error occurred while trying to read the S3 bucket lifecycle configuration\r\ncom.amazonaws.services.s3.model.AmazonS3Exception: The AWS Access Key Id you provided does not exist in our records. (Service: Amazon S3; Status Code: 403; Error Code: InvalidAccessKeyId; Request ID: 9E47D0A340D2E04A)\r\n\tat com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1389)\r\n\tat com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:902)\r\n\tat com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607)\r\n\tat com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376)\r\n\tat com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338)\r\n\tat com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287)\r\n\tat com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3826)\r\n\tat com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3778)\r\n\tat com.amazonaws.services.s3.AmazonS3Client.getBucketLifecycleConfiguration(AmazonS3Client.java:1925)\r\n\tat com.amazonaws.services.s3.AmazonS3Client.getBucketLifecycleConfiguration(AmazonS3Client.java:1912)\r\n\tat com.databricks.spark.redshift.Utils$.checkThatBucketHasObjectLifecycleConfiguration(Utils.scala:127)\r\n\tat com.databricks.spark.redshift.RedshiftRelation.buildScan(RedshiftRelation.scala:90)\r\n\tat org.apache.spark.sql.execution.datasources.DataSourceStrategy$$anonfun$8.apply(DataSourceStrategy.scala:260)\r\n\tat org.apache.spark.sql.execution.datasources.DataSourceStrategy$$anonfun$8.apply(DataSourceStrategy.scala:260)\r\n```\r\n\r\nAfter trying to figure this out with no luck, I decided to try out doing the aws credentials using the IAM instance profiles as described in the README. after setting up my code to use IAM instance profiles, using https://github.com/databricks/spark-redshift/blob/master/src/it/scala/com/databricks/spark/redshift/STSIntegrationSuite.scala as a reference, I got the following error when running locally:\r\n\r\n```\r\nException in thread \"main\" java.lang.IllegalArgumentException: AWS Access Key ID and Secret Access Key must be specified as the username or password (respectively) of a s3 URL, or by setting the fs.s3.awsAccessKeyId or fs.s3.awsSecretAccessKey properties (respectively).\r\n        at org.apache.hadoop.fs.s3.S3Credentials.initialize(S3Credentials.java:70)\r\n        at org.apache.hadoop.fs.s3native.Jets3tNativeFileSystemStore.initialize(Jets3tNativeFileSystemStore.java:80)\r\n        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n        at java.lang.reflect.Method.invoke(Method.java:497)\r\n        at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:191)\r\n        at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)\r\n        at org.apache.hadoop.fs.s3native.$Proxy11.initialize(Unknown Source)\r\n        at org.apache.hadoop.fs.s3native.NativeS3FileSystem.initialize(NativeS3FileSystem.java:326)\r\n        at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2653)\r\n        at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:92)\r\n        at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:2687)\r\n        at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2669)\r\n        at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:371)\r\n        at com.databricks.spark.redshift.Utils$.assertThatFileSystemIsNotS3BlockFileSystem(Utils.scala:156)\r\n        at com.databricks.spark.redshift.RedshiftRelation.<init>(RedshiftRelation.scala:52)\r\n        at com.databricks.spark.redshift.DefaultSource.createRelation(DefaultSource.scala:49)\r\n```\r\n\r\nAfter settings the keys in the hadoop configuration I got it to work locally, but when running on EMR I get the same error when I just set the keys through the hadoop configuration.\r\n\r\nSo it seems that the keys need to be set for the hadoop configuration regardless if the other methods of providing the aws credentials are done. "},"comment":{"url":"https://api.github.com/repos/databricks/spark-redshift/issues/comments/254651883","html_url":"https://github.com/databricks/spark-redshift/issues/276#issuecomment-254651883","issue_url":"https://api.github.com/repos/databricks/spark-redshift/issues/276","id":254651883,"user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"created_at":"2016-10-18T21:59:04Z","updated_at":"2016-10-18T21:59:04Z","body":"This should be fixed by #277."}}
{"actor":{"display_login":"JoshRosen"}}