HOW TO CREATE A SINGLE IAM USER TO ACCESS ONLY SPECIFIC S3 BUCKET OF FOLDER

USE CASE EXAMPLE:

  1. We have to provide a single bucket access to a user.
  2. Need a S3 bucket for your application.

What WE'LL BE DOING:

  1. Create a S3 bucket, We can also used existing one if we have.
  2. Create a Single IAM user Bucket policy.
  3. Create a IAM user
  4. Attached the permission to the user that we have created in step 3.

STEP 1: CREATE A S3 BUCKET

  1. Go to the S3 bucket console.
  2. Click on Create bucket option.
  3. Type the name of the bucket and click on create bucket option.

STEP 2 : CREATE A IAM USER POLICY

  • Go to IAM console
  • Click on Policies and then click on Create Policy.
  • Select JSON option and paste the below json script.
{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Action": [
           "s3:GetBucketLocation",
           "s3:ListAllMyBuckets"
        ],
        "Resource": "arn:aws:s3:::*"
    },
    {
        "Effect": "Allow",
        "Action": "s3:*",
        "Resource": [
            "arn:aws:s3:::YOUR-BUCKET-NAME",
            "arn:aws:s3:::YOUR-BUCKET-NAME/*"
        ]
    },
    {
        "Effect": "Deny",
        "Action": "s3:DeleteBucket",
        "Resource": [
           "arn:aws:s3:::YOUR-BUCKET-NAME",
           "arn:aws:s3:::YOUR-BUCKET-NAME/*"
        ]
    }
  ]
}
  • Next type the policy name and click on create policy.
    Note: Change the highlighted bucket name with your bucket name.

Step 3: Create an IAM User

  1. Click on Users.
  2. Click on Add User.
  3. Type the User Name.
  4. Select the AWS access type Programmatic access or Console or Both.
  5. Click on Attach existing policies.
    search for policies that we have created earlier and select.
  6. Click on Create user.

By using the above tutorial we have created a IAM user and provide a access of single bucket only.

100% LikesVS
0% Dislikes