概念 · 基于 CLF-C02
Policy evaluation and conditions
The order AWS checks policies in, and the condition keys that narrow an Allow.
本课尚未翻译,暂以英文显示。
你在云从业者中已学过
- A policy statement has an effect, actions, resources and an optional condition.
- Everything is denied by default, and an explicit Deny always wins.
- Identity-based policies attach to users, groups and roles. Resource-based policies attach to resources.
1
- Check
- Explicit Deny in any policy
- Needed
- None may match
2
- Check
- Service control policy
- Needed
- Must allow
3
- Check
- Permissions boundary
- Needed
- Must allow
4
- Check
- Session policy
- Needed
- Must allow
5
- Check
- Identity or resource policy
- Needed
- One must allow
| Step | Check | Needed |
|---|---|---|
| 1 | Explicit Deny in any policy | None may match |
| 2 | Service control policy | Must allow |
| 3 | Permissions boundary | Must allow |
| 4 | Session policy | Must allow |
| 5 | Identity or resource policy | One must allow |
1 / 2
1
- Check
- Explicit Deny in any policy
- Needed
- None may match
2
- Check
- Service control policy
- Needed
- Must allow
3
- Check
- Permissions boundary
- Needed
- Must allow
| Step | Check | Needed |
|---|---|---|
| 1 | Explicit Deny in any policy | None may match |
| 2 | Service control policy | Must allow |
| 3 | Permissions boundary | Must allow |
2 / 2
4
- Check
- Session policy
- Needed
- Must allow
5
- Check
- Identity or resource policy
- Needed
- One must allow
| Step | Check | Needed |
|---|---|---|
| 4 | Session policy | Must allow |
| 5 | Identity or resource policy | One must allow |
aws:SourceIp
- Use it to
- Limit to IP ranges
- Example
- Office network only
aws:PrincipalOrgID
- Use it to
- Limit to an organization
- Example
- Any account of ours
aws:MultiFactorAuthPresent
- Use it to
- Require MFA
- Example
- Deny deletes without MFA
aws:SecureTransport
- Use it to
- Require HTTPS
- Example
- Deny when false
aws:SourceVpce
- Use it to
- Limit to an endpoint
- Example
- Private S3 access only
| Condition key | Use it to | Example |
|---|---|---|
| aws:SourceIp | Limit to IP ranges | Office network only |
| aws:PrincipalOrgID | Limit to an organization | Any account of ours |
| aws:MultiFactorAuthPresent | Require MFA | Deny deletes without MFA |
| aws:SecureTransport | Require HTTPS | Deny when false |
| aws:SourceVpce | Limit to an endpoint | Private S3 access only |
1 / 2
aws:SourceIp
- Use it to
- Limit to IP ranges
- Example
- Office network only
aws:PrincipalOrgID
- Use it to
- Limit to an organization
- Example
- Any account of ours
aws:MultiFactorAuthPresent
- Use it to
- Require MFA
- Example
- Deny deletes without MFA
| Condition key | Use it to | Example |
|---|---|---|
| aws:SourceIp | Limit to IP ranges | Office network only |
| aws:PrincipalOrgID | Limit to an organization | Any account of ours |
| aws:MultiFactorAuthPresent | Require MFA | Deny deletes without MFA |
2 / 2
aws:SecureTransport
- Use it to
- Require HTTPS
- Example
- Deny when false
aws:SourceVpce
- Use it to
- Limit to an endpoint
- Example
- Private S3 access only
| Condition key | Use it to | Example |
|---|---|---|
| aws:SecureTransport | Require HTTPS | Deny when false |
| aws:SourceVpce | Limit to an endpoint | Private S3 access only |
是什么
For a request, AWS looks for an explicit Deny in every policy first. If it finds one, the request is denied. Next, each guardrail must allow the request: the service control policy, the permissions boundary and any session policy. Last, an identity-based or a resource-based policy must allow it.
Conditions make an Allow or Deny precise. They are the most tested part of policy writing. The IAM policy simulator shows whether a policy allows or denies an action, so you can test before you attach it.
是什么
NotAction is a trap. An Allow with NotAction allows every action except the listed ones, which is very broad. A Deny with NotAction is the safe pattern: deny everything except these actions unless MFA is present. Avoid NotPrincipal. Write a Deny with a condition instead.
要记住
- Order: explicit Deny, SCP, then boundary and session policy, then an Allow in an identity or resource policy. One exception: in the same account, a resource policy that names the exact IAM user (or the exact role session) can allow access even when the boundary does not. A resource policy that names a role is still limited by the boundary.
- Within one account, an Allow in either the identity policy or the resource policy is enough.
要记住
- Across accounts, both sides must allow.
- Allow with NotAction grants everything else. Check it twice.
- aws:SecureTransport false in a Deny forces HTTPS.
- aws:PrincipalOrgID lets every account in an organization in with one line.
考试中
- “Allow only accounts in our organization to read the bucket” points to a bucket policy with aws:PrincipalOrgID.
- “Reject any request that is not encrypted in transit” points to a Deny when aws:SecureTransport is false.
- “Allow calls only from the office network” points to aws:SourceIp.
别和这些弄混
- Resource-based policiesA policy attached to the resource that names who may use it, including other accounts and services.
- Service control policiesOrganization guardrails: they cap what every principal in the member accounts can do.
- Least privilege in practiceStart with enough access to work, then tighten with real activity and IAM Access Analyzer.
本任务内容 · 1.1
- Shared responsibility model
- Root user and MFA
- Users, groups and roles: authorization model
- Policy evaluation and conditions
- Least privilege in practice
- STS, role switching and cross-account access
- Resource-based policies
- Service control policies
Organizations
Control Tower
IAM Identity Center
- Federating identities into IAM
Directory Service
RAM
- Regions and AZs as the HA building block
- Placing resources