title: S3 PutObject operation gives Access Denied with IAM Role containing Policy granting access to S3
body: <p>I have an IAM role with a custom policy attached to it allowing access to an S3 bucket we'll call <code>foo-bar</code>. I've tried granting access to that specific resource, with <code>PutObject</code> and a couple other actions. That IAM Role is attached to an EC2 instance yet that EC2 instance does not have access to upload files when I use <code>aws s3 sync. s3://foo-bar</code>.</p>
  
  <p>To test if it was an issue with the policy, I just granted S3:* to * resources, and it still won't upload.</p>
  
  <p><code>
  {
      "Version": "2012-10-17",
      "Statement": [
          {
              "Sid": "VisualEditor0",
              "Effect": "Allow",
              "Action": [
                  "cloudformation:ListExports",
                  "s3:*"
              ],
              "Resource": "*"
          }
      ]
  }
  </code></p>
  
  <p>The error I get at the CLI is:</p>
  
  <blockquote>
    <p>upload failed: infrastructure\vpc.template to s3://foo-bar/infrastructure/vpc.template An error occurred (AccessDenied) when calling the PutObject operation: Access Denied</p>
  </blockquote>
  
  <p>Is there something else I need to do in order to give it access? Why isn't the Policy attached to the IAM Role working?</p>