Kubernetes RBAC is the first layer of defense against privilege sprawl. Without strict role definitions, workloads can reach far beyond what they need. When AWS S3 access is in scope, the stakes get higher. A misconfigured role with write access can destroy or corrupt data that was meant to be read-only.
To prevent this, define Kubernetes service accounts with minimal permissions, then bind them to AWS IAM roles that allow read-only access to specific S3 buckets. Use iam.amazonaws.com/role annotations with IRSA (IAM Roles for Service Accounts) to remove static credentials from pods. Make sure IAM policies match the intended scope:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": [
"arn:aws:s3:::my-bucket",
"arn:aws:s3:::my-bucket/*"
]
}
]
}
Lock RBAC at the namespace level. Only bind the service account to the role within a namespace where S3 read-only access is required. Avoid using ClusterRole when a Role is enough. Audit with kubectl auth can-i to validate constraints before deploying workloads.