title: Cannot access s3 file from Flink in AWS EMR
body: <p>We have a long running Flink cluster on AWS EMR. It is configured with the default roles (EMR_EC2_DefaultRole).
  We try to run a Flink job but it cannot access the s3 bucket to read a file.
  We have created the minimal main method code to reproduce it:</p>
  
  <pre><code>String filePath = "s3://&lt;our-bucket&gt;/&lt;the-file&gt;";
  logger.info("Path: " + filePath);
  Path path = Paths.get(filePath);
  logger.info("Successfully got path");
  File file = path.toFile();
  logger.info("Successfully got creds file");
  logger.info("Exists [{}], isFile [{}] ", file.exists(), file.isFile());
  String content = FileUtils.readFileToString(file);
  logger.info("Content [{}]", content);
  </code></pre>
  
  <p>We run the Flink job via the Flink Web UI.
  We get all the logs except the <code>Content</code> log. </p>
  
  <p>The exists log is: <code>Exists [false], isFile [false]</code></p>
  
  <p>We also get the following error:</p>
  
  <pre><code>Caused by: java.io.FileNotFoundException: File 's3:/&lt;our-bucket&gt;/&lt;the-file&gt;' does not exist
      at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:299)
      at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1711)
      at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1748)
      at com.&lt;our-package&gt;.Main.main(Main.java:39)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:529)
      ... 10 more
  </code></pre>
  
  <p>When we ssh to the master EC2 instance and run the following command it works and returns the file content:</p>
  
  <pre><code>sudo hdfs dfs -cat s3://&lt;our-bucket&gt;/&lt;the-file&gt;
  </code></pre>
  
  <p>Please help :)</p>