简体   繁体   中英

Limiting access to AWS S3 with policy is not working as expected

I have a user group which we use for one of our environments in AWS. We are trying to limit access of that group only to specific S3 bucket.

So, I created a policy as follows:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::staging"
        }
    ]
}

If I use AWS policy simulator, all shows as expected (at least looks like it). But, through the app, that uses the API key of a user in this group I am getting access denied when I upload a file.

What am I doing wrong?

This gives the same result

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:GetObjectVersion",
                "s3:DeleteObject",
                "s3:DeleteObjectVersion"
            ],
            "Resource": [
                "arn:aws:s3:::staffila-staging",
                "arn:aws:s3:::staffila-staging/*"
            ]
        }
    ]
}

Use this policy this will work.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket"],
      "Resource": ["arn:aws:s3:::staging"]
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:PutObject",
                "s3:GetObject",
                "s3:GetObjectVersion",
                "s3:DeleteObject",
                "s3:DeleteObjectVersion"
      ],
      "Resource": ["arn:aws:s3:::staging/*"]
    }
  ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM