title: Java AWS SDK - How to upload file using IAM profile from Java API
body: <p>I have just started using AWS for my project. I want to write a project that uploads critical files to s3 bucket. I donot want to expose any secret keys so that all other developers / users can access the uploaded documents. Please provide some pointer how to begin with.</p>
  
  <p>My Current Implementation:</p>
  
  <pre><code> return new AmazonS3Client(new AWSCredentials() {
      @Override
      public String getAWSAccessKeyId() {
      return accessKey;
      }
  
     @Override
     public String getAWSSecretKey() {
       return accessKeySecret;
     }, clientConfiguration )
  </code></pre>
  
  <p>Then I use  amazonS3Client.putObject(putReq); to upload file.
  So, here I am exposing my keys that enables other colleague to download/view the files. Anyone can use it to download/upload file from s3cmd, browser plugins etc.</p>
  
  <p>On reading AWS docs, I got to know I can use EC2 instance and setup IAM profile. BUt I am not sure how can I do with java code. Please provide some link and example</p>