Cloud security IAM policies 2 min read
What does an IAM policy allow?
The monthly report job needs to open monthly/march.csv in S3. Its IAM role has an Allow for that file. Why might S3 still say no?
-
The report job asks for one file
The job sends a request for
s3:GetObjectonarn:aws:s3:::reports/monthly/march.csv. The Allow on its role names the same API action and object, so those fields match.A statement can also require something about the request, such as a particular network path. In this example, the Allow has no extra condition.
In short A statement matches the action, the resource, and any conditions it specifies.
-
The Allow matches. S3 still says no.
S3 also checks the bucket policy. In this example, it explicitly denies reads on this object from outside an approved network. The job is running elsewhere, so that Deny matches the same request.
In short An applicable explicit Deny wins over a matching Allow.
What one IAM policy doesn’t tell you
This example follows one request. To review what else the role can do, check its effective permissions across the resources and request contexts you care about. A wildcard such as monthly/* covers more than this one file.
Keep this
Check the decision for the request you care about.
Start with the job’s action and resource, then check the policies that apply to that request.