An identity-based policy is attached to a user, group or role. It says what that principal can do. A principal is whoever makes the request.
A resource-based policy is attached to a resource. Examples are an S3 bucket policy, an SQS queue policy or a KMS key policy. It has a Principal element that says who can access the resource.
In one account, an allow in either kind of policy is usually enough, as long as no explicit deny applies. KMS is an exception. The key policy must allow access, either directly or by handing the decision to IAM.
Across accounts, both sides must agree:
- The role in account A needs an identity policy that allows
s3:GetObjecton the bucket in B. - The bucket policy in B must allow that role's ARN as the principal.
- If either one is missing, AWS denies the request.
If the objects are encrypted with a customer managed KMS key, the key policy must also allow the role.
- An identity-based policy is attached to a principal. A resource-based policy is attached to a resource and names a Principal.
- In the same account, an allow in either policy is usually enough if there is no explicit deny.
- KMS key policies must allow access themselves.
- Across accounts, the identity policy in A and the resource policy in B must both allow the access.
- Encrypted data also needs the KMS key policy to allow the caller.