<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>

CC BY-SA 4.0
2019-10-30T10:42:54.537Z
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.
fndtn357
CC BY-SA 4.0
2019-10-30T10:55:39.190Z
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.
fndtn357
CC BY-SA 4.0
2019-10-30T09:29:15.447Z
2019-10-30T09:29:15.447Z
Tensibai
<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>

<amazon-web-services><amazon-s3><json>
S3 bucket policy errors
fndtn357
# 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:::",
        "Principal": {
            "AWS": [
                "arn:aws:iam::560184616970:user/"
            ]
        },
        "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:::/*",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::560184616970:user/"
                ]
            },
            "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:::",
      "Principal": {
        "AWS": [
          "arn:aws:iam::560184616970:user/"
        ]
      }
    },
    {
      "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:::/*",
      "Principal": {
        "AWS": [
          "arn:aws:iam::560184616970:user/"
        ]
      }
    },
    {
      "Effect": "Allow",
      "Action": "s3:ListAllMyBuckets",
      "Resource": "*"
    }
  ]
}

An alternative could be to use aws bucket policy generator

> **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.  

---

