anil
anil

Reputation: 469

S3 bucket policy has invalid action

I'm trying to make my entire S3 bucket accessible to a particular user, but when I try to add the policy:

{
  "Id": "Policy1504234405196",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1505369345344",
      "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::testhjh/*",
      "Principal": {
        "AWS": [
          "arn:aws:iam::3164343231:user/testdfs"
        ]
      }
    }
  ]
}

Error: Policy has invalid action.

Could please suggest me what went wrong with the above policy?

Upvotes: 1

Views: 1667

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270089

If you wish to grant access to a specific user or a group of users (eg System Administrators), do not use a Bucket Policy.

Instead, assign permissions directly to the IAM User.

For example, you could add this policy to the testdfs user in IAM:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowGetPut",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3::: testhjh/*"
            ]
        }
    ]
}

This keeps the Bucket Policy cleaner and, if the User leaves your organization, is much easier to clean-up.

(If you're wondering what's wrong with your policy, it's probably the Id field.)

Upvotes: 2

Related Questions