Is there an S3 policy for limiting access to only see/access one bucket?

前端 未结 23 749
孤城傲影
孤城傲影 2020-11-29 15:08

I have a simple bucket that looks like images.mysite.com on my S3 and other buckets containing backups, etc.

I want to allow a specific user to be able

23条回答
  •  自闭症患者
    2020-11-29 15:52

    I found this solution:
    AWS FLOW:
    AWS FLOW

    Bucket policy:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Deny",
          "Principal": "*",
          "Action": "s3:*",
          "Resource": [
            "arn:aws:s3:::MyExampleBucket",
            "arn:aws:s3:::MyExampleBucket/*"
          ],
          "Condition": {
            "StringNotLike": {
              "aws:userId": [
                "AROAEXAMPLEID:*", #Role ID
                "111111111111" #AccountID
              ]
            }
          }
        }
      ]
    }

    IAM policy:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Deny",
          "Principal": "*",
          "Action": "s3:*",
          "Resource": [
            "arn:aws:s3:::MyExampleBucket",
            "arn:aws:s3:::MyExampleBucket/*"
          ],
          "Condition": {
            "StringNotLike": {
              "aws:userId": [
                "AROAEXAMPLEID:*",  #Role ID
                "AIDAEXAMPLEID",  #UserID
                "111111111111"  #AccountID
              ]
            }
          }
        }
      ]
    }

    aws iam get-user -–user-name USER-NAME --profile=ExampleProfile

    aws iam get-role --role-name ROLE-NAME --profile=ExampleProfile

    Source: https://aws.amazon.com/blogs/security/how-to-restrict-amazon-s3-bucket-access-to-a-specific-iam-role/

    P.S. be careful with bucket policy, you can stay out without permissions

提交回复
热议问题