Skip to content

Policies must be valid JSON and the first byte must be '{' #2779

@ronaldpetty

Description

@ronaldpetty

Hello. I have seen this error in a few issues, and I must be tired. It is not obvious to me what the solution should be. I am trying to upload a bucket policy and getting a JSON error. I then downloaded (used UI to enter and it worked fine)/uploaded and get the same error. Any suggestion on how to use the tool to upload this? Keep up the good work!

$ aws s3api get-bucket-policy --bucket cloud-1-$NAME > student-1-bucket.manual.json
$ aws s3api put-bucket-policy --bucket cloud-1-$NAME --policy student-1-bucket.manual.json 

An error occurred (MalformedPolicy) when calling the PutBucketPolicy operation: Policies must be valid JSON and the first byte must be '{'
$ cat student-1-bucket.manual.json 
{
    "Policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"ExampleStatement1\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::934017622331:user/student-1-cloud\"},\"Action\":\"*\",\"Resource\":\"arn:aws:s3:::cloud-1-14604\"}]}"
}
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions