title: Not able to put object in S3 bucket when it does not have public access
body: <p>I'm tying to write object to s3 bucket in my aws account but it fails with below error. </p>
  
  <p>com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 34399CEF4B28B50D; S3 Extended Request ID: </p>
  
  <p>I tried making the bucket public with full access and then I'm able to write to it. </p>
  
  <p>Code I have written to write object to S3 bucket :</p>
  
  <pre><code>......
  
  private final AmazonS3 amazonS3Client;
  
  ........
  
    final PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, s3Key, stream,
                                                                             metadata);
              amazonS3Client.putObject(putObjectRequest);
              final URL url = amazonS3Client.getUrl(bucketName, s3Key);
  </code></pre>
  
  <p>I am building my S3 client as :</p>
  
  <pre><code>@Configuration
  public class AWSConfig {
  
      @Bean
      public AmazonS3 amazonS3Client() {
          String awsRegion = System.getenv("AWS_REGION");
          if (StringUtils.isBlank(awsRegion)) {
              awsRegion = Regions.getCurrentRegion().getName();
          }
          return AmazonS3ClientBuilder.standard()
                                      .withCredentials(new DefaultAWSCredentialsProviderChain())
                                      .withRegion(awsRegion)
                                      .build();
      }
  }
  
  </code></pre>
  
  <p>Please suggest me if I am missing anything and how can I fix the error mentioned above.</p>