Amazon AWS S3 IAM Policy based on namespace or tag

旧巷老猫 提交于 2019-12-05 10:16:13

An IAM policy can grant access to Amazon S3 buckets based on a wildcard.

For example, this policy grants permissions to list the contents of a bucket and retrieve an object from a bucket, but only if the bucket starts with assets-:

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

Note that the Resource section refers to both the bucket (for ListBucket) and the content of the bucket (for GetObject).

Wildcard also work elsewhere in the bucket name, eg: arn:aws:s3:::*-record

It is not possible to grant access to Amazon S3 buckets based on Tags.

ARN format

As an aside, if you're wondering why there are so many colons in the ARN (Amazon Resource Name) for an Amazon S3 bucket, it's because the normal format for an ARN is:

arn:aws:<service name>:<region>:<account>:<resource>

In the case of an Amazon S3 bucket, the region and account can be discerned from the bucket name (which is globally unique), so those parameters are left blank.

Yes indeed it appears I can use IAM policy with ARN arn:aws:s3:::assets-* and arn:aws:s3:::assets-*/*

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!