In this article we will see how to create an Access Policy that will allow us to limit access to this AWS S3 Bucket to only one user and in the same time limit a user to have access to only one AWS S3 bucket.
Many times you will need to separate user access over AWS objects and you need to make sure they don't have access to each other resources unless you want them to.{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::my_bucket"
}
}{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::usrftpjoe-bkt",
"arn:aws:s3:::usrftpjoe-bkt/*"
]
}
]
}
2 - Choose to create a new policy
3 - Choose Create Your Own Policy option
4 - Provide the Name, description and the body the policy. Validate first and then Create the policy.
aws iam put-user-policy --user-name usrFtpJoe --policy-name usrFtpJoe-S3-access-policy --policy-document /tmp/usrFtpJoe-bucket-policy.jsonYou can attach the policy to a user using the Gui or the command line AWS client.
2 - Choose the user to attach the policy to and click on the Attach Policy button.
aws iam attach-user-policy --policy-arn arn:aws:iam::393556751081:policy/usrFtpJoe-S3-access-policy --user-name usrFtpJoeaws iam list-policies --output text | grep <policy name