amazon-web-servicesamazon-s3

amazon s3 invalid principal in bucket policy


I'm trying to create a new bucket policy in the Amazon S3 console and get the error

Invalid principal in policy - "AWS" : "my_username"

The username I'm using in principal is my default bucket grantee.

My policy

{
  "Id": "Policy14343243265",
  "Statement": [
    {
      "Sid": "SSdgfgf432432432435",
      "Action": [
        "s3:DeleteObject",
        "s3:DeleteObjectVersion",
        "s3:GetObject",
        "s3:GetObjectVersion",
        "s3:GetObjectVersionAcl",
        "s3:PutObject",
        "s3:PutObjectAcl",
        "s3:PutObjectVersionAcl"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::my_bucket/*",
      "Principal": {
        "AWS": [
          "my_username"
        ]
      }
    }
  ]
}

I don;t understand why I'm getting the error. What am I doing wrong?


Solution

  • As the error message says, your principal is incorrect. Check the S3 documentation on specifying Principals for how to fix it. As seen in the example policies, it needs to be something like arn:aws:iam::111122223333:root.