Die häufigsten IAM-Fehler
- Root-Konto für den Alltag nutzen
- IAM User mit dauerhaften Access Keys (statt Rollen)
- AdministratorAccess für alle Benutzer
- Kein MFA für privilegierte Konten
- Access Keys in Code (Git-Repos, CI/CD)
Root-Konto absichern
# Root-Konto MFA aktivieren (nur über Konsole möglich!)
# AWS Console → Root User → Security credentials → MFA → Add MFA Device
# Root Access Keys löschen (kritisch!)
aws iam delete-access-key --access-key-id <ROOT_KEY_ID> --user-name root
# AWS Account alias setzen
aws iam create-account-alias --account-alias meine-firma
IAM User mit Least Privilege
# User erstellen
aws iam create-user --user-name max.muster
# Nur notwendige Permissions (S3 read-only)
cat > s3-readonly-policy.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject","s3:ListBucket"],
"Resource": [
"arn:aws:s3:::meine-firma-bucket",
"arn:aws:s3:::meine-firma-bucket/*"
]
}
]
}
EOF
aws iam create-policy --policy-name s3-readonly-policy --policy-document file://s3-readonly-policy.json
aws iam attach-user-policy --user-name max.muster --policy-arn arn:aws:iam::123456789012:policy/s3-readonly-policy
# MFA für User erzwingen
cat > require-mfa-policy.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"NotAction": ["iam:CreateVirtualMFADevice","iam:EnableMFADevice","iam:GetUser"],
"Resource": "*",
"Condition": {"BoolIfExists": {"aws:MultiFactorAuthPresent": "false"}}
}
]
}
EOF
IAM Roles für EC2/Lambda (empfohlen!)
# Role für EC2-Instanz (kein Access Key nötig!)
cat > ec2-assume-role.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"Service": "ec2.amazonaws.com"},
"Action": "sts:AssumeRole"
}]
}
EOF
aws iam create-role --role-name ec2-s3-access-role --assume-role-policy-document file://ec2-assume-role.json
aws iam attach-role-policy --role-name ec2-s3-access-role --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
# Instance Profile (verknüpft Role mit EC2)
aws iam create-instance-profile --instance-profile-name ec2-s3-profile
aws iam add-role-to-instance-profile --instance-profile-name ec2-s3-profile --role-name ec2-s3-access-role
# Beim Starten der Instanz
aws ec2 run-instances --iam-instance-profile Name=ec2-s3-profile --image-id ami-xxx --instance-type t3.small
IAM Access Analyzer
# Analyzer erstellen
aws accessanalyzer create-analyzer --analyzer-name firma-analyzer --type ACCOUNT
# Alle Findings anzeigen
aws accessanalyzer list-findings --analyzer-arn arn:aws:access-analyzer:eu-central-1:123:analyzer/firma-analyzer
AWS Organizations + SCP
# Service Control Policy: Bestimmte Regionen verbieten
cat > deny-regions.json << 'EOF'
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"NotAction": ["iam:*","organizations:*","support:*"],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": ["eu-central-1","eu-west-1"]
}
}
}
]
}
EOF
aws organizations create-policy --name DenyNonEURegions --type SERVICE_CONTROL_POLICY --document file://deny-regions.json
FAQ
Was ist der Unterschied zwischen IAM User und IAM Role?
User: dauerhafter Principal mit permanenten Credentials. Role: temporäre Credentials die assumed werden (von EC2, Lambda, CI/CD, etc.). Für Maschinen immer Roles bevorzugen.
Fazit
IAM richtig konfiguriert – Least Privilege, Rollen statt Users, MFA-Pflicht – ist die wichtigste Sicherheitsmaßnahme in AWS.
AWS IAM und Cloud-Sicherheit für KMU in Heidelberg, Mannheim und der Rhein-Neckar-Region. Anfragen.