title: Amazon S3 Bucket Policy Block User Agent
body: <p>I need to block a specific user agent from amazon s3. I'm fairly new to S3 and typically do this in the .htaccess file which I understand isn't possible with amazon.</p>
  
  <p>I saw this <a href="https://stackoverflow.com/questions/35739337/deny-access-to-user-agent-to-access-a-bucket-in-aws-s3">Deny access to user agent to access a bucket in AWS S3</a>. The solution seems to look something like this:</p>
  
  <pre><code>{ "Version": "2012-10-17", 
    "Statement": [{ 
                "Effect": "Deny", 
                "Principal": "*", 
                "Action": "s3:*",
  
                "Resource": "arn:aws:s3:::bucket/*", 
                "Condition": 
                        { "StringLike": { "aws:UserAgent": "*NSPlayer*" } } 
  }] 
  }
  
  </code></pre>
  
  <p>But, I would still like to allow access to the site to all other users except that user agent. My policy currently looks like this:</p>
  
  <pre><code>{
      "Version": "2012-10-17",
      "Statement": [
          {
              "Sid": "PublicReadGetObject",
              "Effect": "Allow",
              "Principal": "*",
              "Action": "s3:GetObject",
              "Resource": "arn:aws:s3:::www.examplesite.com/*"
          }
      ]
  }
  
  </code></pre>
  
  <p>I get invalid json when I try to implement it. So, I am just curious what is the correct way to format this? I would like to have public access but be able to block a few different user agents. Also, would the user agents be comma separated if I want to block multiple? </p>
  
  <p>Thanks for the help it is much appreciated.</p>