Skip to main content

Cloud Security & IAM

 Cloud Security & IAM: Users, Roles, Policies, Security Groups, and Key Management

📅 Published: Feb 2026
⏱️ Estimated Reading Time: 18 minutes
🏷️ Tags: Cloud Security, IAM, Security Groups, Key Management, Access Control, AWS, Azure, GCP


Introduction: Security is Shared Responsibility

When you move to the cloud, security does not become someone else's problem. Cloud providers secure the infrastructure—the data centers, hardware, and foundational services. You are responsible for everything you put in the cloud: your data, your applications, your access controls, and your configurations.

This shared responsibility model means you must understand how to secure your cloud environment. The tools for cloud security fall into three categories:

  • Identity and Access Management (IAM) — Who can do what

  • Network Security — What traffic is allowed where

  • Data Protection — How data is encrypted and protected

This guide covers the foundational security services you need to protect your cloud infrastructure.


Identity and Access Management (IAM)

What is IAM?

Identity and Access Management (IAM) is the service that controls who is authenticated (signed in) and authorized (has permissions) to use cloud resources. It is the foundation of cloud security.

Think of IAM as the security system for your cloud account. It decides:

  • Who can enter (authentication)

  • What they can do once inside (authorization)

  • Where they can go (resource access)

IAM Across Providers

ProviderService NameKey Concepts
AWSIAMUsers, Groups, Roles, Policies
AzureAzure Active DirectoryUsers, Groups, Service Principals, Roles
Google CloudCloud IAMPrincipals, Roles, Policies

While the terminology differs, the core concepts are consistent across providers.


Users: Individual People

A user represents a person or application that needs access to your cloud resources. Each user has a unique identity with its own credentials.

When to create a user:

  • A developer needs access to the cloud console

  • An application needs API access to your resources

  • A service needs to authenticate to another service

Best practices for users:

  • Create individual users for each person—never share accounts

  • Use strong passwords and enforce regular rotation

  • Require multi-factor authentication (MFA) for all human users

  • Disable or delete users when they leave the organization


Groups: Organizing Users

A group is a collection of users. Instead of attaching permissions to each user individually, you attach permissions to groups, then add users to groups.

Common group structures:

  • Admins — Full access to all resources

  • Developers — Ability to create and modify application resources

  • Operators — Ability to deploy and monitor applications

  • Auditors — Read-only access to all resources

  • Viewers — Read-only access to specific resources

Why groups matter:

  • Simplify permission management

  • Ensure consistent access across users

  • Make onboarding and offboarding easier

  • Provide clear separation of duties


Roles: Assuming Permissions

A role is a set of permissions that can be assumed by users, applications, or services. Unlike users, roles do not have permanent credentials. Instead, they are assumed temporarily.

Think of roles as hats. You put on the appropriate hat for the task you need to perform. When you are done, you take the hat off.

Common role use cases:

  • Cross-account access — A user in one account needs to access resources in another account

  • Service-to-service access — An EC2 instance needs permission to read from S3

  • Temporary elevated access — A developer needs temporary admin permissions

  • Federated access — Employees access cloud resources using their corporate credentials


Policies: Defining Permissions

A policy is a document that defines what actions are allowed or denied on which resources. Policies are written in JSON format.

Policy Structure:

json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::example-bucket"
    },
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject"],
      "Resource": "arn:aws:s3:::example-bucket/*"
    }
  ]
}

Policy Components:

ComponentPurposeExample
EffectAllow or deny"Allow"
ActionWhat operations"s3:GetObject"
ResourceWhich resources"arn:aws:s3:::my-bucket/*"
ConditionWhen the policy applies"IP address must be within corporate range"

Types of Policies

Managed Policies
Pre-built policies created and maintained by the cloud provider. Examples:

  • AdministratorAccess

  • ReadOnlyAccess

  • AmazonS3FullAccess

Customer Managed Policies
Policies you create and manage yourself. These give you fine-grained control over permissions.

Inline Policies
Policies embedded directly on a user, group, or role. Use sparingly—managed policies are easier to maintain.


The Principle of Least Privilege

The most important concept in IAM is least privilege: grant only the permissions required to perform a task, and nothing more.

How to apply least privilege:

  1. Start with minimum permissions. Begin with read-only access. Add permissions as needed.

  2. Use groups, not individual permissions. Grant permissions at the group level.

  3. Use conditions to restrict access. Limit by IP address, time of day, or MFA status.

  4. Audit regularly. Review permissions quarterly. Remove unused permissions.

  5. Use temporary credentials. Prefer roles over long-term access keys.


Security Groups: Instance-Level Firewalls

What Are Security Groups?

Security groups act as virtual firewalls for your compute resources. They control inbound and outbound traffic at the instance level.

Think of security groups as the security guards at the entrance to each building. They check every person entering and leaving against a list of rules.

Security Group Characteristics

Stateful
If you allow inbound traffic, the outbound response is automatically allowed. You do not need to specify return rules.

Allow Only
Security groups only have allow rules. You cannot explicitly deny traffic. To block traffic, you simply do not allow it.

Attached to Resources
Security groups are attached to resources like EC2 instances, RDS databases, and load balancers. A resource can have multiple security groups.


Common Security Group Configurations

Web Server Security Group

DirectionProtocolPortSourcePurpose
InboundTCP800.0.0.0/0HTTP from anywhere
InboundTCP4430.0.0.0/0HTTPS from anywhere
InboundTCP22corporate IPSSH from office
OutboundAllAll0.0.0.0/0All outbound traffic

Database Security Group

DirectionProtocolPortSourcePurpose
InboundTCP3306web-sgMySQL from web servers
InboundTCP22bastion-sgSSH from bastion host
OutboundAllAll0.0.0.0/0All outbound traffic

Bastion Host Security Group

DirectionProtocolPortSourcePurpose
InboundTCP22corporate IPSSH from office
OutboundAllAll0.0.0.0/0All outbound traffic

Security Group Best Practices

Create separate security groups for each tier. Web servers, application servers, and databases should have different security groups.

Use security group references, not IP addresses. Instead of allowing traffic from 10.0.1.0/24, allow from "web-sg". This is more maintainable.

Start with deny all. Only add rules for required traffic.

Restrict administrative access. Limit SSH and RDP access to specific IP addresses. Use bastion hosts when needed.

Remove unused security groups. Regularly audit and delete security groups that are not attached to any resource.


Network ACLs: Subnet-Level Firewalls

What Are Network ACLs?

Network Access Control Lists (NACLs) act as firewalls at the subnet level. They control traffic entering and leaving entire subnets.

Think of NACLs as security checkpoints at the entrance to a neighborhood. They control all traffic entering or leaving that area.

NACL Characteristics

Stateless
You must specify both inbound and outbound rules. Return traffic is not automatically allowed.

Allow and Deny
NACLs can both allow and deny traffic. Deny rules take precedence.

Applied to Subnets
NACLs are attached to subnets, not individual resources. All resources in the subnet are affected.

Rule Evaluation
Rules are evaluated in numerical order. The first matching rule is applied.


NACL vs Security Group

FeatureSecurity GroupNACL
ScopeInstanceSubnet
StateStatefulStateless
RulesAllow onlyAllow and deny
EvaluationAll rulesRule number order
Use CaseInstance-level firewallSubnet-level defense

Use security groups for most access control. Use NACLs for defense in depth and to block specific traffic patterns.


Key Management: Protecting Your Data

Why Key Management Matters

All cloud storage is encrypted by default, but who holds the keys matters. If you use default encryption, the cloud provider manages the keys. If you want control over your encryption keys, you use a key management service.

Key Management Services (KMS) let you create, manage, and control encryption keys used to protect your data.

KMS Across Providers

ProviderService NameFeatures
AWSKey Management Service (KMS)Customer-managed keys, automatic rotation
AzureKey VaultKeys, secrets, certificates
Google CloudCloud KMSHardware security module integration

Types of Keys

Customer-Managed Keys (CMK)
You create and manage the keys. You control rotation, access, and deletion. You are responsible for key security.

AWS-Managed Keys
AWS creates and manages the keys on your behalf. Rotation is automatic. You cannot control the key material.

Cloud Provider-Managed Keys
The cloud provider manages keys for specific services. These are used when you do not specify a customer-managed key.


Key Management Best Practices

Enable automatic key rotation. Rotating keys regularly limits the impact of a compromised key.

Use separate keys for different applications. If one key is compromised, only that application is affected.

Restrict key usage. Limit which services can use each key. A key for S3 should not be used by RDS.

Audit key usage. Enable logging to track when keys are used and by whom.

Plan for disaster recovery. Ensure keys are replicated across regions or have backup copies.


Security Monitoring

CloudTrail (AWS) / Activity Logs (Azure) / Audit Logs (GCP)

These services record all API activity in your cloud account. Every action—creating a resource, modifying a security group, deleting a bucket—is logged.

What to monitor:

  • Failed login attempts

  • Changes to IAM policies

  • Creation or deletion of security groups

  • Changes to encryption keys

  • Unusual API calls from unfamiliar IP addresses

How to monitor:

  • Send logs to a centralized logging system

  • Set up alerts for suspicious activity

  • Review logs weekly for anomalies


Security Services Across Providers

ServiceAWSAzureGoogle Cloud
Configuration ComplianceAWS ConfigAzure PolicySecurity Command Center
Threat DetectionGuardDutySecurity CenterSecurity Command Center
Vulnerability ScanningInspectorSecurity CenterContainer Analysis
Web Application FirewallWAFWAFCloud Armor

Real-World Security Scenarios

Scenario 1: Developer Access

A development team needs access to create and manage resources in a development environment.

IAM Configuration:

  • Create group called "Developers"

  • Attach policy allowing full access to development resources

  • Attach policy allowing read-only access to production resources

  • Add developers to the group

  • Require MFA for all developer accounts

Result: Developers can work freely in development. They can see but not change production.


Scenario 2: Production Database Security

A production database should be accessible only from application servers in the same VPC.

Security Group Configuration:

  • Create security group "database-sg"

  • Inbound rule: allow port 3306 from "application-sg"

  • No inbound rules from anywhere else

  • Outbound: allow all

  • Attach to database instances

Result: Only application servers can connect to the database. The database is not accessible from the internet.


Scenario 3: Encrypted S3 Bucket

An S3 bucket must be encrypted with a customer-managed key that rotates automatically.

Key Management Configuration:

  • Create customer-managed key in KMS

  • Enable automatic rotation (every year)

  • Restrict key usage to S3 only

  • Configure bucket to use the key for default encryption

Result: All objects in the bucket are encrypted with a key the organization controls. The key rotates automatically.


Scenario 4: Cross-Account Access

A central security team needs read-only access to all accounts in the organization.

IAM Configuration:

  • In each account, create a role called "SecurityAuditRole"

  • Attach read-only policies (ReadOnlyAccess, SecurityAudit)

  • Allow the central security account to assume this role

  • Security team assumes the role when needed

Result: Security team can view resources in any account but cannot make changes.


Security Best Practices Checklist

Identity and Access Management

  • Multi-factor authentication enabled for all human users

  • No root account access keys (delete them after setup)

  • Users organized into groups, not individual permissions

  • Policies grant least privilege (no wildcard actions without reason)

  • Regular review of IAM permissions (quarterly)

  • Inactive users and roles removed

  • Temporary credentials used for applications and services

Network Security

  • Security groups restrict access to required ports only

  • SSH/RDP access limited to specific IP addresses

  • Database security groups allow access only from application tiers

  • NACLs provide defense in depth for critical subnets

  • VPC flow logs enabled for security monitoring

  • No open access to administrative ports (22, 3389)

Key Management

  • Customer-managed keys used for sensitive data

  • Automatic key rotation enabled

  • Key usage restricted to specific services

  • Key access logs enabled

  • Keys replicated for disaster recovery

Monitoring

  • API activity logging enabled

  • Alerts configured for suspicious activity

  • Security findings reviewed regularly

  • Compliance scanning enabled for resources


Summary

Security LayerPurposeKey Tools
IdentityWho can accessUsers, Groups, MFA
AuthorizationWhat they can doPolicies, Roles
NetworkWhat traffic is allowedSecurity Groups, NACLs
DataHow data is protectedKMS, Encryption
MonitoringWhat is happeningCloudTrail, Security Hub

Security in the cloud is not a one-time configuration. It is an ongoing practice of applying least privilege, monitoring for threats, and continuously improving your defenses.


Practice Questions

  1. A developer needs access to create EC2 instances but should not be able to delete S3 buckets. How do you configure this?

  2. A web server needs to be accessible from the internet on port 443. A database server should only be accessible from the web server. How do you configure security groups?

  3. Your organization requires that all S3 buckets be encrypted with customer-managed keys that rotate annually. How do you implement this?

  4. A security auditor needs read-only access to all resources in your AWS account. How do you grant this access?

  5. You discover that an IAM user has been using an access key for three years. What security best practice has been violated?


Learn More

Practice cloud security with hands-on exercises in our interactive labs:
https://devops.trainwithsky.com/

Comments

Popular posts from this blog

Introduction to Terraform – The Future of Infrastructure as Code

  Introduction to Terraform – The Future of Infrastructure as Code In today’s fast-paced DevOps world, managing infrastructure manually is outdated . This is where Terraform comes in—a powerful Infrastructure as Code (IaC) tool that allows you to define, provision, and manage cloud infrastructure efficiently . Whether you're working with AWS, Azure, Google Cloud, or on-premises servers , Terraform provides a declarative, automation-first approach to infrastructure deployment. Shape Your Future with AI & Infinite Knowledge...!! Read In-Depth Tech & Self-Improvement Blogs http://www.skyinfinitetech.com Watch Life-Changing Videos on YouTube https://www.youtube.com/@SkyInfinite-Learning Transform Your Skills, Business & Productivity – Join Us Today! In today’s digital-first world, agility and automation are no longer optional—they’re essential. Companies across the globe are rapidly shifting their operations to the cloud to keep up with the pace of innovatio...

📊 Monitoring & Logging in Kubernetes – Tools like Prometheus, Grafana, and Fluentd

  Monitoring & Logging in Kubernetes – Tools like Prometheus, Grafana, and Fluentd Monitoring and logging are essential for maintaining a healthy and well-performing Kubernetes cluster. In this guide, we’ll cover why monitoring is important, key monitoring tools like Prometheus and Grafana, and logging tools like Fluentd to help you gain visibility into your cluster’s performance and logs. Shape Your Future with AI & Infinite Knowledge...!! Want to Generate Text-to-Voice, Images & Videos? http://www.ai.skyinfinitetech.com Read In-Depth Tech & Self-Improvement Blogs http://www.skyinfinitetech.com Watch Life-Changing Videos on YouTube https://www.youtube.com/@SkyInfinite-Learning Transform Your Skills, Business & Productivity – Join Us Today! 🚀 Introduction In today’s fast-paced cloud-native environment, Kubernetes has emerged as the de-facto container orchestration platform. But deploying and managing applications in Kubernetes is just half the ba...

🔒 Kubernetes Security – RBAC, Network Policies, and Secrets Management

  Kubernetes Security – RBAC, Network Policies, and Secrets Management Security is a critical aspect of managing Kubernetes clusters. In this guide, we'll cover essential security mechanisms like Role-Based Access Control (RBAC) , Network Policies , and Secrets Management to help you secure your Kubernetes environment effectively. Shape Your Future with AI & Infinite Knowledge...!! Want to Generate Text-to-Voice, Images & Videos? http://www.ai.skyinfinitetech.com Read In-Depth Tech & Self-Improvement Blogs http://www.skyinfinitetech.com Watch Life-Changing Videos on YouTube https://www.youtube.com/@SkyInfinite-Learning Transform Your Skills, Business & Productivity – Join Us Today! 🚀 Introduction: Why Kubernetes Security Is Non-Negotiable As Kubernetes becomes the backbone of modern cloud-native infrastructure, security is no longer optional—it’s mission-critical . With multiple moving parts like containers, pods, services, nodes, and more, Kuberne...