Cyberithub

Using 3 Easy Steps – How to Create an IAM User and Attach Policy in AWS

In this article, I will take you through the steps to create an IAM User and attach policy to it in AWS.

Create an IAM User and Attach Policy

What is IAM User

An AWS Identity and Access Management (IAM) user is an entity that you create in AWS to represent the person or application that uses it to interact with AWS.

What is Policy

A policy is an object in AWS that, when associated with an identity or resource, defines their permissions.

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 1

Create an User

Step 1:-

To create an IAM User and attach policy we need to first create an IAM User test123 and provide Console access to the User as displayed below.

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 2

Step 2:-

Provide a password with atleast one Capital letter and then Click on Next:Permissions

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 3

Step 3:-

Add the User test123 to the group Admin and then click on Next:Tags

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 4

Step 4:-

We will not use key in our case for Authentication as we are using password based authentication. Click on Next:Review.

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 5

Step 5:-

Review the User and its permissions before clicking on Create User. Once done, click on Create User, it will create an IAM User test123.

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 6

Create a Policy

Here we will use below test policy for our example in which we will allow user to perform List, Get, Upload etc operations on test1 S3 bucket.

Step 1:-

Test-Policy

{
    "Statement": [
        {
          "Action": [
              "s3:ListBucket",
              "s3:GetBucketLocation",
              "s3:ListBucketMultipartUploads",
               "s3:ListBucketVersions"
                    ],
     "Effect": "Allow",
     "Resource": [
           "arn:aws:s3:::test1"
            ]
           },
       {
         "Action": [
              "s3:GetObject",
              "s3:PutObject",
              "s3:DeleteObject",
              "s3:AbortMultipartUpload",
              "s3:ListMultipartUploadParts"
                   ],
      "Effect": "Allow",
      "Resource": [
             "arn:aws:s3:::test1/*"
                  ]
        }
],
   "Version": "2019-11-17"
}

We will provide policy code in JSON tab after clicking on create policy. Once done click on Review Policy.

 

Step 2:-

Here provide the policy name Test-Policy and review the operations allowed to the user on s3 bucket. Once done click on Create Policy.

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 7

 

Attach Test-Policy to User Test123

Step 1:-

Go to Policy Usage tab under Test-policy and click on attach.

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 8

Step 2:-

Select the User to which you want to assign the policy. In our case we will select test123 user. Once selected you will see test123 user is attached to this policy and you are done now.

Using 3 Easy Steps - How to Create an IAM User and Attach Policy in AWS 9

 

Also Read: Top 30 AWS Interview Questions

References: IAM User and Policies

Leave a Comment