Beginner's Guide to Cloud Security: Understanding AWS IAM

Hi, I'm Keerthi Ravilla Subramanyam, a passionate tech enthusiast with a Master's in Computer Science. I love diving deep into topics like Data Structures, Algorithms, and Machine Learning. With a background in cloud engineering and experience working with AWS and Python, I enjoy solving complex problems and sharing what I learn along the way. On this blog, you’ll find articles focused on breaking down DSA concepts, exploring AI, and practical coding tips for aspiring developers. I’m also on a journey to apply my skills in real-world projects like predictive maintenance and data analysis. Follow along for insightful discussions, tutorials, and code snippets to sharpen your technical skills.
Securing cloud resources is essential for any organization, and Amazon Web Services (AWS) offers a comprehensive Identity and Access Management (IAM) service that plays a critical role in managing access to AWS resources. AWS IAM enables administrators to define who can access specific resources, under what conditions, and to what extent. By effectively utilizing IAM, organizations can implement security policies that align with compliance and governance requirements while ensuring users have the appropriate permissions to perform their tasks without compromising sensitive data.
AWS IAM is not just about authentication and authorization; it also provides essential tools for monitoring and auditing access patterns, ensuring that organizations maintain a secure environment. This article will delve into the key components of AWS IAM, highlighting its features and best practices to enhance cloud security.
Key Components of AWS IAM
Users in AWS IAM are individual identities that can log in to AWS and access resources, with each user receiving specific permissions according to their roles within the organization.
Groups are collections of users, and by assigning permissions to a group, administrators can efficiently manage access for multiple users, simplifying permission management.
Roles in AWS IAM are like users but are meant for AWS services or applications, allowing them to temporarily assume permissions for secure interactions between AWS resources.
Policies are documents that define permissions and are attached to users, groups, or roles to specify allowed or denied actions on resources, and they can be managed (AWS-managed or customer-managed) or inline.
Multi-Factor Authentication (MFA) enhances security by requiring users to provide multiple verification factors to access AWS resources, greatly reducing the risk of unauthorized access.
Access keys made up of an access key ID and a secret access key, enable programmatic access to AWS services through the AWS CLI or SDKs, and their proper management is essential for security.
Identity Federation allows users to access AWS resources with credentials from external identity providers like corporate directories or social media accounts.
CloudTrail Integration is used to log API calls, to help organizations track user activity, monitor changes, and meet audit requirements.
IAM Access Analyzer helps administrators identify and refine security by showing which resources can be accessed from outside an account.
Service Control Policies (SCPs) in AWS Organizations manage permissions across multiple accounts, enforcing security and compliance policies.
Project overview
In this project, our primary objective is to utilize AWS Identity and Access Management (IAM) to establish secure access controls for our cloud resources.We will set up two EC2 instances and use effective tagging strategies to improve resource organization and management. By assigning specific tags to each instance, we can better track and allocate costs while maintaining strong security through IAM policies. This hands-on project will give us valuable insights into best practices for identity and access management, ensuring that cloud resources are both secure and efficiently managed.

Step 1: create EC2 instances
In this step, we will create Amazon EC2 (Elastic Compute Cloud) instances, which are scalable virtual servers that enable you to run applications in the cloud. EC2 instances offer flexibility, allowing you to choose various configurations based on your computing needs, including different operating systems and instance types optimized for specific workloads. Let’s get started..
Navigate to EC2 Service:
Access the AWS Management Console and log in with your credentials.
Search for
EC2service in search bar and click on it.
Launch a New Instance:
- Click the
Launch Instancebutton in the EC2 dashboard to create new instances.
- Click the
Set Instance Name and Tags
- In the
Name and Tagssection, set the name for your instance to something unique, like"access_production_yourname"(since instance names must be globally unique).
- In the

To add tags, click on Add Tag and set:
Key:
EnvValue:
productionAdding descriptive tags helps in organizing and identifying your instances easily.
Choose an Amazon Machine Image (AMI):
Ensure that you select an
Amazon Machine Image (AMI)eligible for the Free Tier to avoid unnecessary costs.A good option is
Amazon Linux 2 AMI(Free Tier eligible).
Proceed Without a Key Pair:
- In the
Key Pairsection, chooseProceed without a key pair. (Note: This is generally not recommended, as without a key pair, you won’t be able to SSH into the instance unless you use another method for access.)
- In the

Select Instance Type:
- Choose
t2.micro(Free Tier eligible) as your instance type.
- Choose
Launch Your Instance:
leave everything else to default.
Review all settings, and once everything looks good, click
Launch Instanceto create your EC2 instance.
- Now click on the lanunch instance.
Now follow above steps and create an another instance. With below details:
Name:
access_development_yournametag name:
Envtag Value:
development

Step 2: Creating IAM policy
In this step, we will define an IAM policy, which is a set of permissions that determines what actions are allowed or denied for specific AWS resources. IAM policies are written in JSON format and can be attached to IAM users, groups, or roles to manage access control effectively. By creating and applying IAM policies, you can enforce security best practices and ensure that users have the appropriate level of access to perform their tasks. Let’s move forward.
Navigate to Policies:
Navigate to the
IAM(Identity and Access Management) service.In the left-hand navigation pane, click on
Policies.
Create a New Policy:
- At the top of the Policies page, click on
Create policyto start building a new policy.
- At the top of the Policies page, click on
Switch to JSON Editor:
In the policy creation screen, switch to the
JSONtab for direct code input.Important: Delete all existing code from the editor before proceeding.
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "ec2:*", "Resource": "*", "Condition": { "StringEquals": { "ec2:ResourceTag/Env": "development" } } // Allows all EC2 actions, but only on resources tagged with Env=development. }, { "Effect": "Allow", "Action": "ec2:Describe*", "Resource": "*" // Allows read-only describe actions on all EC2 resources. }, { "Effect": "Deny", "Action": [ "ec2:DeleteTags", "ec2:CreateTags" ], "Resource": "*" // Denies tag creation and deletion on all EC2 resources. } ] }
Copy the provided policy (or your desired policy) and paste it into the JSON editor.

Review and Customize the Policy:
Once you're satisfied with the policy, click
Nextto move to the next step.Add Policy Details:
Fill in the policy's details:
Name:
DevEnvironmentPolicyDescription:
IAM Policy for project's development environment

Create the Policy:
Review the information carefully.
When you're ready, click
Create policyto complete the process.
You have sucessfully created the IAM policy.
Step 3: Create an AWS Account Alias
In this step, we will create an account alias, which is a user-friendly name for your AWS account that simplifies the login process. By setting up an alias, you can replace the default AWS account ID in the sign-in URL with a more recognizable name, making it easier to access your account. This feature enhances usability and helps improve the overall user experience when managing your AWS resources. Let’s proceed.
In the Account Alias section on the right side of the IAM dashboard, click on Create.

In the Preferred alias field, type
account-alias-yourname, replacingyournamewith your preferred name.
After entering the alias, click Create alias to confirm and apply it.
Step 4: creating IAM User group
In this step, we will create an IAM user group, which is a collection of IAM users that share the same permissions. User groups simplify the management of permissions by allowing you to assign policies to the group rather than individually to each user. This approach streamlines access control, ensuring that users within the group have consistent permissions to AWS resources.
In the left-hand navigation panel, select
User groups.Click on Create group to initiate the setup for your first user group.
Configure the User Group:
Name: Enter
dev-groupas the name for your user group.Attach Permission Policies: Select
DevEnvironmentPolicyfrom the list of available policies.
Click on
Create user group.You’ll see a success message confirming the creation of your user group. Now, let's proceed to add users to this group.

Step 5: Create a new user
In this step, we will create IAM users, which are unique identities within your AWS account that allow individuals or applications to securely access AWS resources. IAM users can have specific permissions assigned to them through policies, enabling granular control over what actions they can perform and which resources they can access. By creating IAM users, we can effectively manage access and enhance security in our AWS environment.
Create a New User:
Select Users from the left-hand navigation panel, then click
Create userto set up your new user account.In the User name field, enter
dev-yourname(replace "yourname" with your actual name).
Select “
I want to create an IAM user” option.Under console password,section select
autogenerated password.Uncheck the option for
Users must create a new password at next sign-in - Recommended.
Assign Permissions:
To grant permissions to the user, select the checkbox next to the user group you previously created,
dev-group.Click Next to continue.
Create the User:
Finally, click Create user.
You’ll see a success message along with the sign-in details for your new user. Keep this page open for reference.
Remember to save this login details.

Step 6: Test your user's access
Sign In as the New IAM User
Copy the Console Sign-in URL: From the IAM tab, copy the Console sign-in URL for your newly created user.
Open an Incognito Window:
In your web browser, open a new incognito or private browsing window.
Access the Console Sign-in URL: Paste the copied URL into the incognito window.
Use the User name and Console password provided in your IAM tab to log in.

Navigate to the EC2 Console:
Make sure you are in the same Region where your production and development instances are deployed.
Click on the
Instanceslink in the left-hand navigation pane.
The dashboard panel, shows the access denied already for different regions.
Test Access on Production Instance
Find your production instance in the list and select it.
Click on the Actions dropdown.
Select Instance State > Manage instance state.
Choose the Stop option and click on Change state.
Confirm by selecting Stop.

An error message will appear at the top of the page indicating that you are not authorized to stop this instance. This is expected as the IAM policy restricts permissions on production instances.

Next, let’s proceed with changing the state of your development instances. Follow the same steps as outlined above: select your development instance and attempt to modify its state.

It should work, as the policy does not restrict state changes for instances tagged with 'development’.

Remember to delete all the resources you created to avoid being billed.
Congratulations! 🎉 You’ve successfully created your own IAM policies and implemented key components of AWS Identity and Access Management. By focusing on IAM, you’ve improved the security and compliance of your cloud environment. Visit the network.org platform for more interesting projects and continue learning. Stay tuned for our upcoming articles in the AWS series.






