Introduction to AWS IAM: Identity and Access Management.
Tags: user, group, policies, roles
Published: 2024-03-28 19:28:40


**Overview:** AWS Identity and Access Management (IAM) offers comprehensive management of permissions within your AWS account, allowing precise regulation of user access to specific services and resources. With IAM policies, you can tailor permissions for users or applications, ensuring they only have access to the resources necessary for their tasks, and defining conditions for how and when access is granted.



## **Key Components of IAM:**

1. Users: Users are entities that represent individual people, applications, or services that interact with AWS. Each user has a unique name and credentials (username and password or access keys) for accessing AWS resources.

2. Groups: Groups are collections of users. Instead of attaching policies directly to individual users, you can create groups, assign policies to them, and then add users to those groups. This simplifies permission management, especially in larger organizations with multiple users.
 
3. Policies: Policies are JSON documents that define permissions. You can attach policies to users, groups, or roles to grant or restrict access to AWS resources. Policies specify what actions are allowed or denied on which resources. AWS provides managed policies with predefined permissions, or you can create custom policies tailored to your specific needs.

4. Roles: Roles are similar to users, but they are not associated with a specific person or identity. Instead, roles are meant to be assumed by entities such as AWS services, applications, or users from another AWS account. Roles define a set of permissions, and when an entity assumes a role, it temporarily takes on those permissions.




## **Core Concepts:**

1. Authentication: The process of verifying the identity of a user, application, or service. IAM supports various authentication methods, including username/password authentication for users, and access keys for programmatic access by applications or scripts.

2. Authorization: Determining what actions a user, group, or role is allowed to perform on AWS resources. This is controlled through IAM policies, which define the permissions associated with each entity.
 
3. Least Privilege: Following the principle of least privilege means granting users, groups, and roles only the permissions they need to perform their intended tasks, and no more. This reduces the risk of unauthorized access and potential security breaches.


## **Project Objective**
In this project, the following tasks will be accomplished. 

1. Create a user, 
2. ⁠Create a group and add the user to the group, 
3. ⁠Attach 3 policies to that group: the user must have the ability to create IAM user, vpc, and s3 policies, 
4. ⁠Create a customized customer-managed policy to deny a user access to creating an RDS instance snapshot and allow the user to create an EC2 instance,
5. ⁠Create an organization: add two accounts to the organization 1: Developer account and 2: An operations account and switch roles between the accounts.


A step-by-step pictorial approach will be used for better guidance and understanding.


To start with, Open your web browser and go to the AWS Management Console at https://aws.amazon.com/console/.
Sign in using your AWS account credentials.

Once you're logged in, navigate to the IAM dashboard.

In the top-left corner, search for "IAM" in the services search bar, and select "IAM" from the results.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ysvr0z8qe8df0yp79eya.png)

**IAM allows you to manage access to AWS services and resources securely.**


**Task 1:**

Click on users in the left-hand corner to create a user. Then click on create a user.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afd5ivb6p64k0aqo5dlx.png)

Input your desired user name, then click next.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6nn73xipfi15kot8z32o.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isj2yy7ftd7l92yl0tok.png)


**Task 2:**
Next, our task is to create a user group and add the user into the group. 

To achieve this, click on create user group. Input the group user name and click on create user group.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpo227rlxnxfak5kpqyp.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmowwvldkjh9nnzo979q.png)

We then need to add the user to the group we created. To get this done, click on the group name and then click on add users.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fg1awvigisgz7hiqadeq.png)

Then input the user name in the search bar and add user to the group.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p8jnxcvd7qocmlqj71g.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lf85lxjq03pdvn6swn5x.png)
We have successfully created a user and added the user to a group.
 


**Task 3:**
**The next step is to attach policies to the user group we created.**


To attach policies click on permissions by the right of users tab.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8vqoipfup7xcun0eacas.png)

then click on the add permission arrow on the right-hand side, and click on attach policies.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i4zlips831yd26sojbiq.png)

On the permission policies screen, to add IAM policy, search for IAMfullacess.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxkk75c1v3eoi60dk6qu.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g34skcl2gczl2p1qhm1s.png)

check on IAMfullacess and click attach policies 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ur5dh1i7kuq41yms4hu6.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eb8z7xkuok0zld881zrp.png)

IAMfullacess policy has been successfully attached to the group.

Repeat the above steps to attach vpc and s3 policies to the group.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0s876g3jjh1cxiulx77k.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oyzlic5awkl9f0dsl3kz.png)


![All 3 policies attached](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3k40f6eqkbegsj5coo0d.png)

All three policies have been attached to the group.



**Task 4:**

**Now, we have to customize a customer-managed policy to deny a user from creating an RDS instance snapshot, while allowing the user to create an EC2 instance. **

To create a customized policy, we will click on the permission policy arrow by the right hand, then click on create an inline policy.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kw02h6tsoa0m06hnzays.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9eaf4u63q20rhuan38rh.png)

On services, choose RDS


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rg8zbkeo2xer9bwt39k5.png)

Select All RDS and all resources, then select deny, and click next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x7soz0xh9vjsvntttem7.png)

Then create policy.

To allow the user to create an EC2 instance, go to inline policy, and click on services, then click on EC2.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/99p6889czodf2dvi2anf.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgnmp05he1r36b0fdorj.png)

All policies have been applied.


**Task 5:**

The last task of this project is to create two accounts and be able to switch between roles.


**Creating accounts under the AWS organization to switch roles.**

First, go to AWS organization and click on create an account, fill in the details, and create an account.
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zo8vohjfavqzefmguhqn.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3ah4cf26pprwrwqdp9a.png)

After creating an account, we will need to create roles for each account. To do this, navigate to role in IAM features, then create roles.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lcjkx947u2mnkza41uef.png)

Under trusted entity type, select AWS account and under an AWS account choose this account, then next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hgut6w37jcjwsbhjlcw0.png)

Attach administrator access to the role, click next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pyfiz86sd3eq4i1k1cjv.png)

Put in the role name and create role.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hflwfe9cwvrmerzwzvjr.png)

Do this for any more roles you want to create.

To switch roles, navigate to IAM dashboard and click on the top right corner arrow, then click on switch role.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvhzs42rjbsurmypuu8y.png)

Put in the account ID and the ARN characters from the account role then switch.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v25sbive0y4gjgv99xvn.png)

Thanks for reading through to this point. I'm assured you have gotten insightful steps to guide you on exploring the AWS IAM feature. 

Feel free to comment and ask questions where necessary, I'll be glad to respond.

Cheers.