title: Spring Boot Amazon AWS S3 Bucket File Download - Access Denied
body: <p>I have an auto-configured AWS, Spring Boot application, and I'm trying to setup an endpoint that will simply download a particular file from a given bucket in Amazon S3. I uploaded a JPEG file into the bucket from my computer using the AWS console - now I'm trying to download that file using my Spring Boot API.</p>
  
  <p>I'm getting the following error: <code>com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied;</code></p>
  
  <p>I have created a user and a group (user is in the group) on AWS console; the user/group has full access permissions on S3 as well as administrator access. I downloaded the access-key/secret-key pair and, for testing purposes, literally pasted the keys into my application.properties file as shown below (keys are not shown here, obviously :) ).</p>
  
  <p>I'm confused as to why I'm still getting access denied. I've been searching and working on this for a while; I can't seem to find a solution to this issue that is specific to Spring Boot. Any help would be greatly appreciated.</p>
  
  <p>application.properties:</p>
  
  <pre><code>cloud.aws.credentials.accessKey=myaccesskey
  cloud.aws.credentials.secretKey=mysecretkey
  cloud.aws.credentials.instanceProfile=false
  cloud.aws.stack.auto=false
  
  cloud.aws.region.auto=true
  cloud.aws.region.static=myregion
  </code></pre>
  
  <p>SimpleResourceLoadingBean.java:</p>
  
  <pre><code>@RestController
  public class SimpleResourceLoadingBean {
  
      private static Logger log = LoggerFactory.getLogger(HealthMonitorApplication.class);
  
      @Autowired
      private ResourceLoader resourceLoader;
  
  
      @RequestMapping("/getresource")
      public String resourceLoadingMethod() throws IOException {
          log.info("IN RESOURCE LOADER");
  
          Resource resource = this.resourceLoader.getResource("s3://s3.amazonaws.com/mybucket/myfile.ext");
  
          InputStream inputStream = resource.getInputStream();
  
          return inputStream.toString();
      }
  }
  </code></pre>
  
  <p>pom.xml (Just the dependencies that are relevant to the question)</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-starter-aws&lt;/artifactId&gt;
              &lt;version&gt;1.1.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
              &lt;artifactId&gt;spring-cloud-aws-autoconfigure&lt;/artifactId&gt;
              &lt;version&gt;1.1.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>