SAA-C03 ยท Roles, federation and cross-account access
Resource-based policies
Policies attached to resources (S3 bucket, SQS queue, KMS key, Lambda function), the Principal element, and when a resource policy is the right tool instead of a role.
Key points
- Resource-based policy: attached to the resource itself, such as an S3 bucket policy, SQS queue policy, KMS key policy or Lambda function policy.
- Principal element: names who gets access.
- Always inline.
- Use it when another account or service must reach one resource while keeping its own permissions, which switching into a role does not allow.
Source: https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html
Practice questions
Which policy element appears in a resource-based policy to say who is granted access, but is not used in an identity-based policy?
- Effect
- Principal
- Action
- Condition
Show answer
Answer: B. Principal
A resource-based policy must name the grantee in Principal, because the policy is attached to the resource rather than to an identity. Effect, Action and Resource/Condition are used by both policy types.
Which of these can have a resource-based policy attached directly?
- An Amazon S3 bucket
- An IAM user group
- An Amazon SQS queue
- An AWS KMS key
- An Amazon EC2 instance
Show answer
Answer: A. An Amazon S3 bucket, C. An Amazon SQS queue, D. An AWS KMS key
S3 buckets, SQS queues and KMS keys all accept resource-based policies. An IAM user group is an identity container that takes identity-based policies, and an EC2 instance gets permissions through its role, not a resource policy.
You can write one customer managed resource-based policy and attach it to many S3 buckets at once.
Show answer
Answer: False
False. Resource-based policies are inline only: each bucket has its own bucket policy. Managed policies (AWS or customer managed) exist only for identity-based policies.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
