Answers: <p>It looks like you tried to compile multiple policies into one.<br>
  Each original had a statement with its array of statements and you nested them.</p>
  
  <p>This (untested) should work with each statement block within the array of Statement of the policy:</p>
  
  <pre><code>{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "s3:ListBucket",
          "s3:GetBucketLocation",
          "s3:ListBucketMultipartUploads"
        ],
        "Resource": "arn:aws:s3:::&lt;my bucket&gt;",
        "Principal": {
          "AWS": [
            "arn:aws:iam::560184616970:user/&lt;my username&gt;"
          ]
        }
      },
      {
        "Effect": "Allow",
        "Action": [
          "s3:AbortMultipartUpload",
          "s3:DeleteObject",
          "s3:DeleteObjectVersion",
          "s3:GetObject",
          "s3:GetObjectAcl",
          "s3:GetObjectVersion",
          "s3:GetObjectVersionAcl",
          "s3:PutObject",
          "s3:PutObjectAcl",
          "s3:PutObjectAclVersion"
        ],
        "Resource": "arn:aws:s3:::&lt;my-bucket&gt;/*",
        "Principal": {
          "AWS": [
            "arn:aws:iam::560184616970:user/&lt;my-username&gt;"
          ]
        }
      },
      {
        "Effect": "Allow",
        "Action": "s3:ListAllMyBuckets",
        "Resource": "*"
      }
    ]
  }
  </code></pre>
  
  <p>An alternative could be to use <a href="https://awspolicygen.s3.amazonaws.com/policygen.html" rel="nofollow noreferrer">aws bucket policy generator</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-30T10:42:54.537Z
Answers: I did use the Policy generator and did not realize that each Statement block was a separate policy. Using the example provided I am getting Error:
  Missing required field Principal. And if I add a Principal to the last section I then I get Error: Policy has invalid action.
Answers: fndtn357
Answers: CC BY-SA 4.0
Answers: 2019-10-30T10:55:39.190Z
Answers: I'll move this to the Amazon support forums - I did create a policy that validates but allows public access from the website URL and Amazon complains about Public Access. Thanks for your help.
Answers: fndtn357
Answers: CC BY-SA 4.0
Answers: 2019-10-30T09:29:15.447Z
Answers: 2019-10-30T09:29:15.447Z
Answers: Tensibai
Body: <p>I have the following bucket policy for Amazon S3, which is giving the following error:</p>
  
  <blockquote>
    <p>Error: Invalid bucket policy syntax.</p>
  </blockquote>
  
  <p>Either it is a JSON syntax error or a Policy error.</p>
  
  <p>This is the policy I am trying and failing with:</p>
  
  <pre><code>{
      "Version": "2012-10-17",
      "Statement": [{
          "Effect": "Allow",
          "Action": [
              "s3:ListBucket",
              "s3:GetBucketLocation",
              "s3:ListBucketMultipartUploads"
          ],
          "Resource": "arn:aws:s3:::&lt;my bucket&gt;",
          "Principal": {
              "AWS": [
                  "arn:aws:iam::560184616970:user/&lt;my username&gt;"
              ]
          },
          "Statement": [{
              "Effect": "Allow",
              "Action": [
                  "s3:AbortMultipartUpload",
                  "s3:DeleteObject",
                  "s3:DeleteObjectVersion",
                  "s3:GetObject",
                  "s3:GetObjectAcl",
                  "s3:GetObjectVersion",
                  "s3:GetObjectVersionAcl",
                  "s3:PutObject",
                  "s3:PutObjectAcl",
                  "s3:PutObjectAclVersion"
              ],
              "Resource": "arn:aws:s3:::&lt;my-bucket&gt;/*",
              "Principal": {
                  "AWS": [
                      "arn:aws:iam::560184616970:user/&lt;my-username&gt;"
                  ]
              },
              "Statement": [{
                  "Effect": "Allow",
                  "Action": "s3:ListAllMyBuckets",
                  "Resource": "*"
              }]
          }]
      }]
  }
  </code></pre>
  
  <p>Can anyone give me guidance here?</p>
  
Tags: <amazon-web-services><amazon-s3><json>
Title: S3 bucket policy errors
UserDisplayName: fndtn357
ThreadText: # S3 bucket policy errors
  
  (Asked by: username_0 on 2019-10-29)
  
  I have the following bucket policy for Amazon S3, which is giving the following error:
  
  > Error: Invalid bucket policy syntax.
  
  Either it is a JSON syntax error or a Policy error.
  
  This is the policy I am trying and failing with:
  
  ```
  {
      "Version": "2012-10-17",
      "Statement": [{
          "Effect": "Allow",
          "Action": [
              "s3:ListBucket",
              "s3:GetBucketLocation",
              "s3:ListBucketMultipartUploads"
          ],
          "Resource": "arn:aws:s3:::<my bucket>",
          "Principal": {
              "AWS": [
                  "arn:aws:iam::560184616970:user/<my username>"
              ]
          },
          "Statement": [{
              "Effect": "Allow",
              "Action": [
                  "s3:AbortMultipartUpload",
                  "s3:DeleteObject",
                  "s3:DeleteObjectVersion",
                  "s3:GetObject",
                  "s3:GetObjectAcl",
                  "s3:GetObjectVersion",
                  "s3:GetObjectVersionAcl",
                  "s3:PutObject",
                  "s3:PutObjectAcl",
                  "s3:PutObjectAclVersion"
              ],
              "Resource": "arn:aws:s3:::<my-bucket>/*",
              "Principal": {
                  "AWS": [
                      "arn:aws:iam::560184616970:user/<my-username>"
                  ]
              },
              "Statement": [{
                  "Effect": "Allow",
                  "Action": "s3:ListAllMyBuckets",
                  "Resource": "*"
              }]
          }]
      }]
  }
  
  ```
  
  Can anyone give me guidance here?
  
  **Tags:** amazon-web-services, amazon-s3, json
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-30. Score: 1
  
  It looks like you tried to compile multiple policies into one.  
  Each original had a statement with its array of statements and you nested them.
  
  This (untested) should work with each statement block within the array of Statement of the policy:
  
  ```
  {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "s3:ListBucket",
          "s3:GetBucketLocation",
          "s3:ListBucketMultipartUploads"
        ],
        "Resource": "arn:aws:s3:::<my bucket>",
        "Principal": {
          "AWS": [
            "arn:aws:iam::560184616970:user/<my username>"
          ]
        }
      },
      {
        "Effect": "Allow",
        "Action": [
          "s3:AbortMultipartUpload",
          "s3:DeleteObject",
          "s3:DeleteObjectVersion",
          "s3:GetObject",
          "s3:GetObjectAcl",
          "s3:GetObjectVersion",
          "s3:GetObjectVersionAcl",
          "s3:PutObject",
          "s3:PutObjectAcl",
          "s3:PutObjectAclVersion"
        ],
        "Resource": "arn:aws:s3:::<my-bucket>/*",
        "Principal": {
          "AWS": [
            "arn:aws:iam::560184616970:user/<my-username>"
          ]
        }
      },
      {
        "Effect": "Allow",
        "Action": "s3:ListAllMyBuckets",
        "Resource": "*"
      }
    ]
  }
  
  ```
  
  An alternative could be to use [aws bucket policy generator](https://awspolicygen.s3.amazonaws.com/policygen.html)
  
  > **Comments:**
  > **username_0**: I did use the Policy generator and did not realize that each Statement block was a separate policy. Using the example provided I am getting Error: Missing required field Principal. And if I add a Principal to the last section I then I get Error: Policy has invalid action.  
  > **username_0**: I'll move this to the Amazon support forums - I did create a policy that validates but allows public access from the website URL and Amazon complains about Public Access. Thanks for your help.  
  
  ---
  
  