Cloud Security Fundamentals

Cloud security is shared responsibility — the cloud provider secures the platform; you secure what you run on it. Most cloud security incidents come from customer mistakes, not cloud-provider failures. Misconfigured S3 buckets, exposed credentials, overly permissive IAM, missing encryption.

This page covers the foundations: IAM, encryption, network security, secrets, and the operational practices.

Shared responsibility

The provider secures:

You secure:

The boundary varies by service. Lambda: provider does more. EC2: customer does more. Understand the boundary for each service you use.

IAM is the foundation

Most cloud security failures involve IAM mistakes. The principles:

Least privilege

Grant only permissions that are needed. Refuse "AdministratorAccess" unless genuinely required.

{
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::my-bucket/data/*"
}

Specific service, specific action, specific resource. Not s3:* and not *:*.

Roles, not users

Workloads should authenticate via roles, not user credentials. EC2 has instance profiles; Lambda has execution roles; ECS has task roles. Code calling AWS gets temporary credentials from the role.

This is dramatically more secure than embedded user credentials.

MFA everywhere

Every human IAM user with console access should have MFA. The root user especially. The cost is minimal; the risk reduction is large.

Separate accounts for separation of concerns

Production, staging, dev, security tools, billing — separate accounts. Cross-account access via roles. Limits blast radius of compromise.

AWS Organizations lets you manage many accounts coherently.

Encryption

At rest

All data at rest should be encrypted. Most managed services encrypt by default; some don't and need explicit configuration.

The choice between provider-managed keys and customer-managed (KMS) keys is real:

In transit

All data in transit should be encrypted with TLS 1.2+.

Most cloud services support this; some require explicit configuration. Check that your application is using TLS, not falling back to plaintext.

Key management

KMS (AWS) handles encryption keys at scale. CMKs (Customer Master Keys) encrypt data keys; data keys encrypt actual data.

Key practices:

Network security

Security groups

Instance-level firewall. Default deny; allow specific traffic.

Inbound: TCP 443 from ALB security group only
Outbound: TCP 443 to anywhere

The reference-by-security-group pattern (ALB SG can talk to backend SG) is more secure than CIDR blocks for internal traffic.

NACLs

Subnet-level firewall. Stateless. Used for broad rules; security groups for specific.

Public subnets

Limit what's in public subnets — only load balancers and bastion hosts. Application servers and databases in private subnets.

NAT Gateway

For private subnets that need outbound internet (downloads, API calls). Doesn't allow inbound; private resources stay private.

VPC endpoints

For accessing AWS services without going through the internet. S3 endpoint, DynamoDB endpoint, etc. Faster and more secure than route through internet.

Secrets management

Don't put secrets in code

Database passwords, API keys, encryption keys. Never committed to git.

Don't put secrets in environment variables (raw)

Lambda environment variables, ECS task definitions. These are stored unencrypted in cloud control plane. Reference Secrets Manager / Parameter Store instead.

Use a secrets service

Application reads secrets at startup or on-demand. Secrets are rotated; service handles the mechanics.

Logging and monitoring

CloudTrail (AWS)

Audit log of all API calls. Enable; ship to a separate account for tamper-resistance.

VPC Flow Logs

Network traffic logs. Useful for incident investigation.

Application logs

Structured; centralized; not in CloudTrail.

GuardDuty (AWS) / equivalent

Anomaly detection. Catches known-bad patterns (compromised credentials, crypto-mining, data exfiltration). Enable.

Config

Tracks configuration changes. Useful for compliance and post-incident review.

Common cloud security failures

Public S3 buckets

The classic. Bucket made public for some reason; sensitive data exposed. Use:

Exposed access keys

Access keys in code or in public git repos. Bots scan GitHub continuously for AWS keys.

Use:

Over-permissioned IAM

Too-broad policies because narrowing is hard. The fix:

Misconfigured security groups

0.0.0.0/0:22 (SSH from anywhere). Bots find these; brute-force or use leaked keys. Fix:

Outdated dependencies

Vulnerable libraries, vulnerable AMIs, vulnerable base images. Scan continuously; patch promptly.

Common failure patterns

Further Reading