My Journey to AWS Certified Cloud Practitioner: Day 2 – Identity and Access Management in AWS

In today's post, I’ll be diving into Identity and Access Management (IAM) in AWS, which is a crucial part of ensuring secure access to your AWS resources. Understanding IAM is essential not just for the AWS Certified Cloud Practitioner (CCP) exam, but also for managing users and permissions in any cloud environment.

IAM is a global service, meaning it does not require regional setup, and the configurations you make are applied globally across your AWS account. It’s the central way to manage identities, control access, and define who can do what in your AWS environment.

Let’s explore the key concepts of IAM, including users, groups, permissions, policies, and how permissions inheritance works.

IAM Users and User Groups

In AWS IAM, a user is an identity created to represent a person or application that interacts with AWS resources. Each user can have its own set of security credentials (like access keys) and specific permissions. For example, you might have different users for developers, administrators, and database managers in your organization.

User groups allow you to group multiple users and manage their permissions collectively. Instead of assigning permissions to each user individually, you can create groups (e.g., "Developers", "Admins") and assign the necessary permissions to the group. Users added to the group will automatically inherit the permissions assigned to that group. This is useful for managing access efficiently at scale.

IAM Permissions: The Principle of Least Privilege

AWS IAM uses permissions to control what actions users, groups, and roles can perform on AWS resources. Permissions are defined using IAM policies, which are JSON documents that specify which actions are allowed or denied on which resources.

When granting permissions, it's essential to follow the principle of least privilege, which means providing only the permissions necessary for a user to complete their tasks—no more, no less. By applying least privilege, you reduce the potential damage caused by accidental or malicious activity.

Example of IAM Permissions JSON Structure

IAM permissions are expressed in JSON format, with two main components: actions and resources.

Here's an example of an IAM policy that grants permission to read objects from an S3 bucket:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my-bucket/*"
        }
    ]
}
  • "Effect": Can be "Allow" or "Deny" depending on whether the action is permitted.

  • "Action": Defines the specific action allowed or denied (e.g., s3:GetObject for reading from an S3 bucket).

  • "Resource": Specifies the AWS resource the permission applies to (e.g., an S3 bucket in this case).

Structure of IAM Policies

IAM policies are structured documents written in JSON, and they consist of the following elements:

  1. Version: Specifies the policy language version (the most common version is "2012-10-17").

  2. Statement: Defines individual permissions, where each permission can either allow or deny access to an AWS resource.

A policy contains one or more statements, and each statement has:

  • Effect: Whether the permission is allowed or denied.

  • Action: The specific AWS action, such as s3:PutObject, ec2:StartInstances.

  • Resource: The ARN (Amazon Resource Name) of the AWS resource the action applies to.

  • Condition (Optional): Conditions that must be met for the policy to apply, such as IP address restrictions or multi-factor authentication requirements.

Here’s an example of a more complex policy that allows reading objects from an S3 bucket but only from a specific IP address:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-bucket/*",
      "Condition": {
        "IpAddress": {
          "aws:SourceIp": "192.0.2.0/24"
        }
      }
    }
  ]
}

IAM Policy Inheritance

IAM policies can be attached at different levels (user, group, or role) and AWS will evaluate all policies together. Policy inheritance means that permissions are cumulative: a user can inherit permissions from both their group and their attached policies.

For example, let's say a user belongs to two groups:

  • The "Developers" group has a policy allowing access to S3 and EC2.

  • The "Admins" group has a policy allowing access to IAM resources.

The user will inherit permissions from both groups, giving them access to S3, EC2, and IAM resources. However, if any policy explicitly denies access to a resource, that denial will take precedence over any allowed permissions.

Here’s an example where a user inherits permissions from multiple policies:

  • Group 1 Policy:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::*"
    }
  ]
}
  • Group 2 Policy:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iam:*",
      "Resource": "*"
    }
  ]
}

In this case, the user will have access to both S3 and IAM actions due to policy inheritance.

Conclusion

IAM is a cornerstone of AWS security, allowing precise control over who can access what resources and under what conditions. By managing users, groups, and permissions effectively, you can implement the principle of least privilege, ensuring that users only have the access they truly need.

As I continue my journey, I’m excited to delve deeper into the various AWS services and understand how they integrate with IAM to offer a secure, scalable cloud environment. Stay tuned for more!

1
Subscribe to my newsletter

Read articles from Krishna Prasanth Gurram directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Krishna Prasanth Gurram
Krishna Prasanth Gurram

🌐 Welcome to my blog, I'm a dedicated and passionate web developer with a strong commitment to creating exceptional online experiences. 💻 🚀 As a technology enthusiast, I thrive on staying at the forefront of web development trends and harnessing the latest tools and technologies to build engaging and dynamic websites. My mission is to turn digital dreams into reality. 🤝 Collaboration and communication are at the core of my work philosophy. I thrive in team environments and value the power of cross-functional collaboration, always seeking opportunities to learn and grow from my peers. 🌟 If you're looking for a passionate web developer who can transform your ideas into captivating online solutions, let's connect! I'm excited to explore new opportunities and create digital experiences that make a lasting impact. Let's build the web of the future together! 👋 #WebDevelopment #PassionForCode #DigitalExperiences #WebDeveloper #Innovation