ladderlore
请求新指南
  • 输入服务名称,例如 S3 或 IAM。

概念 · 基于 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
The evaluation order, from the first check to the last.

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

2 / 2

  • 4

    Check
    Session policy
    Needed
    Must allow
  • 5

    Check
    Identity or resource policy
    Needed
    One must allow
The evaluation order, from the first check to the last.
  • 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 keys that appear again and again in scenarios.

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

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 keys that appear again and again in scenarios.

是什么

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.