User to view the buckets but not allowed to create a bucket

0

I am trying to configure my IAM policy which would allow a user to only view the bucket and place objects, delete and update the folder/files within that bucket, but deny bucket creation. I have already added the following to my IAM policy but it is of no use as it will still allow the user to create a bucket. How to achieve this goal?

	"Version": "2012-10-17",
	"Statement": [
		{
			"Action": [
				"s3:ListAllMyBuckets"
			],
			"Effect": "Allow",
			"Resource": [
				"arn:aws:s3:::*"
			]
		},
                {
			"Effect": "Deny",
			"Action": "s3:CreateBucket",
			"Resource": "*"
		},
		{
			"Effect": "Deny",
			"Action": "s3:CreateBucket",
			"NotResource": "arn:aws:s3:::*"
		},
		{
			"Action": [
				"s3:ListBucket",
				"s3:GetBucketLocation"
			],
			"Effect": "Allow",
			"Resource": "arn:aws:s3:::my-bucket"
		},
		{
			"Effect": "Allow",
			"Action": [
				"s3:GetObject",
				"s3:PutObject",
				"s3:DeleteObject"
			],
			"Resource": "arn:aws:s3:::my-bucket/*"
		}
	]
}
2개 답변
0

To achieve your goal of allowing a user to view and manage objects within a specific S3 bucket, but denying the ability to create new buckets, you can use the following IAM policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetBucketLocation"
            ],
            "Resource": "arn:aws:s3:::my-bucket"
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:PutObject",
                "s3:DeleteObject"
            ],
            "Resource": "arn:aws:s3:::my-bucket/*"
        },
        {
            "Effect": "Deny",
            "Action": "s3:CreateBucket",
            "Resource": "*"
        }
    ]
}

Here's what this policy does:

  1. The first statement allows the user to list the contents of the my-bucket bucket and get the bucket's location.
  2. The second statement allows the user to get objects, put objects, and delete objects within the my-bucket bucket.
  3. The third statement explicitly denies the s3:CreateBucket action on all resources (*), effectively preventing the user from creating new buckets.
profile pictureAWS
답변함 2달 전
profile picture
전문가
검토됨 2달 전
  • I did try this policy, but after logging in as the IAM user, it is still able to create a bucket! will it take time for this policy to take affect? I'm assuming it will be instantly but it doesn't work. What could be the reason and what are other options? Thanks.

0

Hello,

the second deny seems to contradict this by trying to allow the same action on any resource not matching

	{
		"Effect": "Deny",
		"Action": "s3:CreateBucket",
		"NotResource": "arn:aws:s3:::*"
	},
Paul
답변함 2달 전
profile picture
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠