

**推出 的新主控台體驗 AWS WAF**

您現在可以使用更新後的體驗，在主控台的任何位置存取 AWS WAF 功能。如需詳細資訊，請參閱[使用 主控台](https://docs.aws.amazon.com/waf/latest/developerguide/working-with-console.html)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# AWS WAF 如何使用 IAM
<a name="security_iam_service-with-iam"></a>

本節說明如何搭配使用 IAM 的功能 AWS WAF。

在您使用 IAM 管理對 的存取之前 AWS WAF，請先了解可使用哪些 IAM 功能 AWS WAF。






**您可以搭配 使用的 IAM 功能 AWS WAF**  

| IAM 功能 | AWS WAF 支援 | 
| --- | --- | 
|  [身分型政策](#security_iam_service-with-iam-id-based-policies)  |   是  | 
|  [資源型政策](#security_iam_service-with-iam-resource-based-policies)  |   是  | 
|  [政策動作](#security_iam_service-with-iam-id-based-policies-actions)  |   是  | 
|  [政策資源](#security_iam_service-with-iam-id-based-policies-resources)  |   是  | 
|  [政策條件索引鍵 (服務特定)](#security_iam_service-with-iam-id-based-policies-conditionkeys)  |   是  | 
|  [ACL](#security_iam_service-with-iam-acls)  |   否   | 
|  [ABAC(政策中的標籤)](#security_iam_service-with-iam-tags)  |   部分  | 
|  [臨時憑證](#security_iam_service-with-iam-roles-tempcreds)  |   是  | 
|  [轉送存取工作階段 (FAS)](#security_iam_service-with-iam-principal-permissions)  |   是  | 
|  [服務角色](#security_iam_service-with-iam-roles-service)  |   是  | 
|  [服務連結角色](#security_iam_service-with-iam-roles-service-linked)  |   是  | 

若要全面了解 AWS WAF 和其他 AWS 服務如何與大多數 IAM 功能搭配使用，請參閱《IAM *使用者指南*》中的與 IAM [AWS 搭配使用的 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。

## 的身分型政策 AWS WAF
<a name="security_iam_service-with-iam-id-based-policies"></a>

**支援身分型政策：**是

身分型政策是可以附加到身分 (例如 IAM 使用者、使用者群組或角色) 的 JSON 許可政策文件。這些政策可控制身分在何種條件下能對哪些資源執行哪些動作。如需了解如何建立身分型政策，請參閱《*IAM 使用者指南*》中的[透過客戶管理政策定義自訂 IAM 許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html)。

使用 IAM 身分型政策，您可以指定允許或拒絕的動作和資源，以及在何種條件下允許或拒絕動作。如要了解您在 JSON 政策中使用的所有元素，請參閱《*IAM 使用者指南*》中的 [IAM JSON 政策元素參考](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html)。

若要檢視 AWS WAF 身分型政策的範例，請參閱 [的身分型政策範例 AWS WAF](security_iam_id-based-policy-examples.md)。

## 中的資源型政策 AWS WAF
<a name="security_iam_service-with-iam-resource-based-policies"></a>

**支援資源型政策：**是

資源型政策是附加到資源的 JSON 政策文件。資源型政策的最常見範例是 IAM *角色信任政策*和 Amazon S3 *儲存貯體政策*。在支援資源型政策的服務中，服務管理員可以使用它們來控制對特定資源的存取權限。對於附加政策的資源，政策會定義指定的主體可以對該資源執行的動作以及在何種條件下執行的動作。您必須在資源型政策中[指定主體](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html)。委託人可以包含帳戶、使用者、角色、聯合身分使用者或 AWS 服務。

如需啟用跨帳戶存取權，您可以在其他帳戶內指定所有帳戶或 IAM 實體作為資源型政策的主體。如需詳細資訊，請參閱《*IAM 使用者指南*》中的 [IAM 中的快帳戶資源存取](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html)。

AWS WAF 使用資源型政策來支援跨帳戶共用規則群組。您可以將資源型政策設定提供給 AWS WAF API 呼叫`PutPermissionPolicy`或對等的 CLI 或 SDK 呼叫，以與其他 AWS 帳戶共用您擁有的規則群組。如需其他資訊，包括其他可用語言文件的範例和連結，請參閱 AWS WAF API 參考中的 [PutPermissionPolicy](https://docs.aws.amazon.com/waf/latest/APIReference/API_PutPermissionPolicy.html)。此功能無法透過其他方式使用，例如 主控台或 CloudFormation。

## 的政策動作 AWS WAF
<a name="security_iam_service-with-iam-id-based-policies-actions"></a>

**支援政策動作：**是

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

JSON 政策的 `Action` 元素描述您可以用來允許或拒絕政策中存取的動作。政策會使用動作來授予執行相關聯動作的許可。



若要查看每個 AWS WAF 的動作和許可清單，請參閱*服務授權參考*中的 [AWS WAF V2 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awswafv2.html#awswafv2-actions-as-permissions)。

中的政策動作在動作之前 AWS WAF 使用以下字首：

```
wafv2
```

如需在單一陳述式中指定多個動作，請用逗號分隔。

```
"Action": [
      "wafv2:action1",
      "wafv2:action2"
         ]
```



您也可以使用萬用字元 (\$1) 來指定多個動作。例如，若要在 中指定以 AWS WAF 開頭的所有動作`List`，請包含下列動作：

```
"Action": "wafv2:List*"
```

若要檢視 AWS WAF 身分型政策的範例，請參閱 [的身分型政策範例 AWS WAF](security_iam_id-based-policy-examples.md)。

### 需要額外許可設定的動作
<a name="security_iam_action-additions"></a>

有些動作需要 *服務授權參考*中 [AWS WAF V2 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awswafv2.html#awswafv2-actions-as-permissions)中無法完整描述的許可。本節提供額外的許可資訊。

**Topics**
+ [`AssociateWebACL` 的許可](#security_iam_action-AssociateWebACL)
+ [`DisassociateWebACL` 的許可](#security_iam_action-DisassociateWebACL)
+ [`GetWebACLForResource` 的許可](#security_iam_action-GetWebACLForResource)
+ [`ListResourcesForWebACL` 的許可](#security_iam_action-ListResourcesForWebACL)

#### `AssociateWebACL` 的許可
<a name="security_iam_action-AssociateWebACL"></a>

本節列出使用 AWS WAF 動作 將保護套件 (Web ACL) 與資源建立關聯所需的許可`AssociateWebACL`。

對於 Amazon CloudFront 分佈，請使用 CloudFront 動作 ，而不是此動作`UpdateDistribution`。如需詳細資訊，請參閱《*Amazon CloudFront API 參考*》中的 [UpdateDistribution](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_UpdateDistribution.html)。

**Amazon API Gateway REST API**  
需要許可，才能在 REST API 資源類型`SetWebACL`上呼叫 API Gateway，以及在保護套件 (Web ACL) 上呼叫 AWS WAF `AssociateWebACL` 。

```
{
    "Sid": "AssociateWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:AssociateWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "AssociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "apigateway:SetWebACL"
    ],
    "Resource": [
        "arn:aws:apigateway:*::/restapis/*/stages/*"
    ]
}
```

**Application Load Balancer**  
需要許可才能呼叫 Application Load Balancer 資源類型的`elasticloadbalancing:SetWebACL`動作，以及在保護套件 (Web ACL) `AssociateWebACL`上呼叫 AWS WAF 。

```
{
    "Sid": "AssociateWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:AssociateWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "AssociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "elasticloadbalancing:SetWebACL"
    ],
    "Resource": [
        "arn:aws:elasticloadbalancing:*:account-id:loadbalancer/app/*/*"
    ]
}
```

**AWS AppSync GraphQL API**  
需要許可，才能在 GraphQL API 資源類型上呼叫 AWS AppSync `SetWebACL` ，以及在保護套件 (Web ACL) 上呼叫 AWS WAF `AssociateWebACL` 。

```
{
    "Sid": "AssociateWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:AssociateWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "AssociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "appsync:SetWebACL"
    ],
    "Resource": [
        "arn:aws:appsync:*:account-id:apis/*"
    ]
}
```

**Amazon Cognito 使用者集區**  
需要許可，才能對使用者集區資源類型呼叫 Amazon Cognito `AssociateWebACL`動作，以及在保護套件 (Web ACL) 上呼叫 AWS WAF `AssociateWebACL` 。

```
{
    "Sid": "AssociateWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:AssociateWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "AssociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "cognito-idp:AssociateWebACL"
    ],
    "Resource": [
        "arn:aws:cognito-idp:*:account-id:userpool/*"
    ]
}
```

**AWS App Runner 服務**  
需要許可，才能在 App Runner 服務資源類型上呼叫 App Runner `AssociateWebACL`動作，以及在 Web ACL 上呼叫 AWS WAF `AssociateWebACL` 。

```
{
    "Sid": "AssociateWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:AssociateWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "AssociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "apprunner:AssociateWebAcl"
    ],
    "Resource": [
        "arn:aws:apprunner:*:account-id:service/*/*"
    ]
}
```

**AWS 已驗證的存取執行個體**  
需要許可才能在 Verified Access 執行個體資源類型上呼叫 `ec2:AssociateVerifiedAccessInstanceWebAcl`動作，以及在 Web ACL 上呼叫 AWS WAF `AssociateWebACL` 。

```
{
    "Sid": "AssociateWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:AssociateWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "AssociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "ec2:AssociateVerifiedAccessInstanceWebAcl"
    ],
    "Resource": [
        "arn:aws:ec2:*:account-id:verified-access-instance/*"
    ]
}
```

#### `DisassociateWebACL` 的許可
<a name="security_iam_action-DisassociateWebACL"></a>

本節列出使用 AWS WAF 動作 取消保護套件 (Web ACL) 與資源的關聯所需的許可`DisassociateWebACL`。

對於 Amazon CloudFront 分佈，請使用 CloudFront 動作`UpdateDistribution`搭配空的保護套件 (Web ACL) ID。如需詳細資訊，請參閱《*Amazon CloudFront API 參考*》中的 [UpdateDistribution](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_UpdateDistribution.html)。

**Amazon API Gateway REST API**  
需要在 REST API 資源類型`SetWebACL`上呼叫 API Gateway 的許可。不需要呼叫 的許可 AWS WAF `DisassociateWebACL`。

```
{
    "Sid": "DisassociateWebACL",
    "Effect": "Allow",
    "Action": [
        "apigateway:SetWebACL"
    ],
    "Resource": [
        "arn:aws:apigateway:*::/restapis/*/stages/*"
    ]
}
```

**Application Load Balancer**  
需要對 Application Load Balancer 資源類型呼叫 `elasticloadbalancing:SetWebACL`動作的許可。不需要呼叫 的許可 AWS WAF `DisassociateWebACL`。

```
{
    "Sid": "DisassociateWebACL",
    "Effect": "Allow",
    "Action": [
        "elasticloadbalancing:SetWebACL"
    ],
    "Resource": [
        "arn:aws:elasticloadbalancing:*:account-id:loadbalancer/app/*/*"
    ]
}
```

**AWS AppSync GraphQL API**  
需要許可才能呼叫 AWS AppSync `SetWebACL` GraphQL API 資源類型。不需要呼叫 的許可 AWS WAF `DisassociateWebACL`。

```
{
    "Sid": "DisassociateWebACL",
    "Effect": "Allow",
    "Action": [
        "appsync:SetWebACL"
    ],
    "Resource": [
        "arn:aws:appsync:*:account-id:apis/*"
    ]
}
```

**Amazon Cognito 使用者集區**  
需要許可，才能對使用者集區資源類型呼叫 Amazon Cognito `DisassociateWebACL`動作並呼叫 AWS WAF `DisassociateWebACL`。

```
{
    "Sid": "DisassociateWebACL1",
    "Effect": "Allow",
    "Action": "wafv2:DisassociateWebACL",
    "Resource": "*"
},
{
    "Sid": "DisassociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "cognito-idp:DisassociateWebACL"
    ],
    "Resource": [
        "arn:aws:cognito-idp:*:account-id:userpool/*"
    ]
}
```

**AWS App Runner 服務**  
需要對 App Runner 服務資源類型呼叫 App Runner `DisassociateWebACL`動作和 呼叫的許可 AWS WAF `DisassociateWebACL`。

```
{
    "Sid": "DisassociateWebACL1",
    "Effect": "Allow",
    "Action": "wafv2:DisassociateWebACL",
    "Resource": "*"
},
{
    "Sid": "DisassociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "apprunner:DisassociateWebAcl"
    ],
    "Resource": [
        "arn:aws:apprunner:*:account-id:service/*/*"
    ]
}
```

**AWS 已驗證的存取執行個體**  
需要對 Verified Access 執行個體資源類型呼叫 `ec2:DisassociateVerifiedAccessInstanceWebAcl`動作和 呼叫的許可 AWS WAF `DisassociateWebACL`。

```
{
    "Sid": "DisassociateWebACL1",
    "Effect": "Allow",
    "Action": "wafv2:DisassociateWebACL",
    "Resource": "*"
},
{
    "Sid": "DisassociateWebACL2",
    "Effect": "Allow",
    "Action": [
        "ec2:DisassociateVerifiedAccessInstanceWebAcl"
    ],
    "Resource": [
        "arn:aws:ec2:*:account-id:verified-access-instance/*"
    ]
}
```

#### `GetWebACLForResource` 的許可
<a name="security_iam_action-GetWebACLForResource"></a>

本節列出使用 AWS WAF 動作 取得受保護資源的保護套件 (Web ACL) 所需的許可`GetWebACLForResource`。

對於 Amazon CloudFront 分佈，請使用 CloudFront 動作 ，而不是此動作`GetDistributionConfig`。如需詳細資訊，請參閱《*Amazon CloudFront API 參考*》中的 [GetDistributionConfig](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_GetDistributionConfig.html)。

**注意**  
`GetWebACLForResource` 需要 許可才能呼叫 `GetWebACL`。在這種情況下， `GetWebACL`只會 AWS WAF 使用 來驗證您的帳戶是否具有存取 `GetWebACLForResource` 傳回的保護套件 (Web ACL) 所需的許可。當您呼叫 時`GetWebACLForResource`，您可能會收到錯誤，指出您的帳戶未獲授權在 資源`wafv2:GetWebACL`上執行。 AWS WAF 不會將此類型的錯誤新增至 AWS CloudTrail 事件歷史記錄。

**Amazon API Gateway REST API、Application Load Balancer 和 AWS AppSync GraphQL API**  
需要呼叫 AWS WAF `GetWebACLForResource` 和 保護套件 (Web ACL) `GetWebACL`的許可。

```
{
    "Sid": "GetWebACLForResource",
    "Effect": "Allow",
    "Action": [
        "wafv2:GetWebACLForResource",
        "wafv2:GetWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
}
```

**Amazon Cognito 使用者集區**  
需要許可才能呼叫使用者集區資源類型的 Amazon Cognito `GetWebACLForResource`動作，以及呼叫 AWS WAF `GetWebACLForResource` 和 `GetWebACL`。

```
{
    "Sid": "GetWebACLForResource1",
    "Effect": "Allow",
    "Action": [
        "wafv2:GetWebACLForResource",
        "wafv2:GetWebACL"
    ],
    "Resource": [ 
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "GetWebACLForResource2",
    "Effect": "Allow",
    "Action": [
        "cognito-idp:GetWebACLForResource"
    ],
    "Resource": [
        "arn:aws:cognito-idp:*:account-id:userpool/*"
    ]
}
```

**AWS App Runner 服務**  
需要許可才能呼叫 App Runner 服務資源類型的 App Runner `DescribeWebAclForService`動作，以及呼叫 AWS WAF `GetWebACLForResource`和 `GetWebACL`。

```
{
    "Sid": "GetWebACLForResource1",
    "Effect": "Allow",
    "Action": [
        "wafv2:GetWebACLForResource",
        "wafv2:GetWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "GetWebACLForResource2",
    "Effect": "Allow",
    "Action": [
        "apprunner:DescribeWebAclForService"
    ],
    "Resource": [
        "arn:aws:apprunner:*:account-id:service/*/*"
    ]
}
```

**AWS 已驗證的存取執行個體**  
需要許可才能呼叫 Verified Access 執行個體資源類型的 `ec2:GetVerifiedAccessInstanceWebAcl`動作，以及呼叫 AWS WAF `GetWebACLForResource` 和 `GetWebACL`。

```
{
    "Sid": "GetWebACLForResource1",
    "Effect": "Allow",
    "Action": [
        "wafv2:GetWebACLForResource",
        "wafv2:GetWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "GetWebACLForResource2",
    "Effect": "Allow",
    "Action": [
        "ec2:GetVerifiedAccessInstanceWebAcl"
    ],
    "Resource": [
        "arn:aws:ec2:*:account-id:verified-access-instance/*"
    ]
}
```

#### `ListResourcesForWebACL` 的許可
<a name="security_iam_action-ListResourcesForWebACL"></a>

本節列出使用 AWS WAF 動作 擷取保護套件 (Web ACL) 的受保護資源清單所需的許可`ListResourcesForWebACL`。

對於 Amazon CloudFront 分佈，請使用 CloudFront 動作 ，而不是此動作`ListDistributionsByWebACLId`。如需詳細資訊，請參閱《*Amazon CloudFront API 參考*》中的 [ListDistributionsByWebACLId](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ListDistributionsByWebACLId.html)。

**Amazon API Gateway REST API、Application Load Balancer 和 AWS AppSync GraphQL API**  
需要呼叫 AWS WAF `ListResourcesForWebACL` Web ACL 的許可。

```
{
    "Sid": "ListResourcesForWebACL",
    "Effect": "Allow",
    "Action": [
        "wafv2:ListResourcesForWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
}
```

**Amazon Cognito 使用者集區**  
需要對使用者集區資源類型呼叫 Amazon Cognito `ListResourcesForWebACL`動作和呼叫 AWS WAF 的許可`ListResourcesForWebACL`。

```
{
    "Sid": "ListResourcesForWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:ListResourcesForWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "ListResourcesForWebACL2",
    "Effect": "Allow",
    "Action": [
        "cognito-idp:ListResourcesForWebACL"
    ],
    "Resource": [
        "arn:aws:cognito-idp:*:account-id:userpool/*"
    ]
}
```

**AWS App Runner 服務**  
需要對 App Runner 服務資源類型呼叫 App Runner `ListAssociatedServicesForWebAcl`動作和 呼叫的許可 AWS WAF `ListResourcesForWebACL`。

```
{
    "Sid": "ListResourcesForWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:ListResourcesForWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "ListResourcesForWebACL2",
    "Effect": "Allow",
    "Action": [
        "apprunner:ListAssociatedServicesForWebAcl"
    ],
    "Resource": [
        "arn:aws:apprunner:*:account-id:service/*/*"
    ]
}
```

**AWS 已驗證的存取執行個體**  
需要許可才能呼叫 Verified Access 執行個體資源類型的 `ec2:DescribeVerifiedAccessInstanceWebAclAssociations`動作，以及呼叫 AWS WAF `ListResourcesForWebACL`。

```
{
    "Sid": "ListResourcesForWebACL1",
    "Effect": "Allow",
    "Action": [
        "wafv2:ListResourcesForWebACL"
    ],
    "Resource": [
        "arn:aws:wafv2:region:account-id:regional/webacl/*/*"
    ]
},
{
    "Sid": "ListResourcesForWebACL2",
    "Effect": "Allow",
    "Action": [
        "ec2:DescribeVerifiedAccessInstanceWebAclAssociations"
    ],
    "Resource": [
        "arn:aws:ec2:*:account-id:verified-access-instance/*"
    ]
}
```

## 的政策資源 AWS WAF
<a name="security_iam_service-with-iam-id-based-policies-resources"></a>

**支援政策資源：**是

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

`Resource` JSON 政策元素可指定要套用動作的物件。最佳實務是使用其 [Amazon Resource Name (ARN)](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html) 來指定資源。若動作不支援資源層級許可，使用萬用字元 (\$1) 表示該陳述式適用於所有資源。

```
"Resource": "*"
```

若要查看 AWS WAF 資源類型及其 ARNs的清單，請參閱*服務授權參考*中的 [AWS WAF V2 定義的資源](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awswafv2.html#awswafv2-resources-for-iam-policies)。若要了解您可以使用哪些動作指定每個資源的 ARN，請參閱 [AWS WAF V2 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awswafv2.html#awswafv2-actions-as-permissions)。若要允許或拒絕存取資源子集 AWS WAF ，請在政策的 `resource`元素中包含資源的 ARN。

資源ARNs 格式如下： AWS WAF `wafv2`

```
arn:partition:wafv2:region:account-id:scope/resource-type/resource-name/resource-id
```

如需 ARN 規格的一般資訊，請參閱 中的 [Amazon Resource Name (ARNs)](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) Amazon Web Services 一般參考。

下列列出 `wafv2` 資源 ARNs 特有的要求：
+ region**：針對您用來保護 Amazon CloudFront 分佈 AWS WAF 的資源，將此設定為 `us-east-1`。否則，請將此設定為搭配受保護區域資源使用的 區域。
+ *範圍*：將範圍設定為 `global`，以搭配 Amazon CloudFront 分佈使用`regional`，或搭配 AWS WAF 支援的任何區域資源使用。區域資源是 Amazon API Gateway REST API、Application Load Balancer、a AWS AppSync GraphQL API、Amazon Cognito 使用者集區、 AWS App Runner 服務和 AWS Verified Access 執行個體。
+ *resource-type*：指定下列其中一個值：`webacl`、`rulegroup`、`regexpatternset`、 `ipset`或 `managedruleset`。
+ *resource-name*：指定您提供 AWS WAF 資源的名稱，或指定萬用字元 (`*`) 來表示符合 ARN 中其他規格的所有資源。您必須指定資源名稱和資源 ID，或同時指定萬用字元。
+ *resource-id*：指定資源的 AWS WAF ID，或指定萬用字元 (`*`)，以指出符合 ARN 中其他規格的所有資源。您必須指定資源名稱和資源 ID，或同時指定萬用字元。

例如，下列 ARN 會指定區域 `111122223333`中帳戶區域範圍的所有保護套件 (Web ACLs)`us-west-1`：

```
arn:aws:wafv2:us-west-1:111122223333:regional/webacl/*/*
```

下列 ARN 指定名為 的規則群組`MyIPManagementRuleGroup`，具有區域 `111122223333`中帳戶的全域範圍`us-east-1`：

```
arn:aws:wafv2:us-east-1:111122223333:global/rulegroup/MyIPManagementRuleGroup/1111aaaa-bbbb-cccc-dddd-example-id
```

若要檢視 AWS WAF 身分型政策的範例，請參閱 [的身分型政策範例 AWS WAF](security_iam_id-based-policy-examples.md)。

## 的政策條件索引鍵 AWS WAF
<a name="security_iam_service-with-iam-id-based-policies-conditionkeys"></a>

**支援服務特定政策條件金鑰：**是

管理員可以使用 AWS JSON 政策來指定誰可以存取內容。也就是說，哪個**主體**在什麼**條件**下可以對什麼**資源**執行哪些**動作**。

`Condition` 元素會根據定義的條件，指定陳述式的執行時機。您可以建立使用[條件運算子](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html)的條件運算式 (例如等於或小於)，來比對政策中的條件和請求中的值。若要查看所有 AWS 全域條件索引鍵，請參閱《*IAM 使用者指南*》中的[AWS 全域條件內容索引鍵](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)。

此外， AWS WAF 支援下列條件索引鍵，您可以使用這些索引鍵為您的 IAM 政策提供精細篩選：
+ **wafv2：LogDestinationResource**

  此條件金鑰會取得記錄目的地的 Amazon Resource Name (ARN) 規格。這是您在使用 REST API 呼叫 時為記錄目的地提供的 ARN`PutLoggingConfiguration`。

  您可以明確指定 ARN，也可以指定 ARN 的篩選。下列範例指定篩選具有特定位置和字首的 Amazon S3 儲存貯ARNs。

  ```
  "Condition": { "ArnLike": { "wafv2:LogDestinationResource": "arn:aws:s3:::aws-waf-logs-suffix/custom-prefix/*" } }
  ```
+ **wafv2：LogScope**

  此條件索引鍵定義字串中記錄組態的來源。目前，這一律設定為預設值 `Customer`，這表示記錄目的地由您擁有和管理。

若要查看 AWS WAF 條件索引鍵的清單，請參閱《*服務授權參考*》中的 [AWS WAF V2 的條件索引鍵](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awswafv2.html#awswafv2-policy-keys)。若要了解您可以使用條件金鑰的動作和資源，請參閱 [AWS WAF V2 定義的動作](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awswafv2.html#awswafv2-actions-as-permissions)。

若要檢視 AWS WAF 身分型政策的範例，請參閱 [的身分型政策範例 AWS WAF](security_iam_id-based-policy-examples.md)。

## 中的 ACLs AWS WAF
<a name="security_iam_service-with-iam-acls"></a>

**支援 ACL：**否 

存取控制清單 (ACL) 可控制哪些主體 (帳戶成員、使用者或角色) 擁有存取某資源的許可。ACL 類似於資源型政策，但它們不使用 JSON 政策文件格式。

## ABAC 搭配 AWS WAF
<a name="security_iam_service-with-iam-tags"></a>

**支援 ABAC (政策中的標籤)：**部分

屬性型存取控制 (ABAC) 是一種授權策略，根據稱為標籤的屬性定義許可權。您可以將標籤連接至 IAM 實體 AWS 和資源，然後設計 ABAC 政策，以便在委託人的標籤符合資源上的標籤時允許操作。

如需根據標籤控制存取，請使用 `aws:ResourceTag/key-name`、`aws:RequestTag/key-name` 或 `aws:TagKeys` 條件索引鍵，在政策的[條件元素](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)中，提供標籤資訊。

如果服務支援每個資源類型的全部三個條件金鑰，則對該服務而言，值為 **Yes**。如果服務僅支援某些資源類型的全部三個條件金鑰，則值為 **Partial**。

如需 ABAC 的詳細資訊，請參閱《*IAM 使用者指南*》中的[使用 ABAC 授權定義許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction_attribute-based-access-control.html)。如要查看含有設定 ABAC 步驟的教學課程，請參閱《*IAM 使用者指南*》中的[使用屬性型存取控制 (ABAC)](https://docs.aws.amazon.com/IAM/latest/UserGuide/tutorial_attribute-based-access-control.html)。

## 搭配 使用臨時登入資料 AWS WAF
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

**支援臨時憑證：**是

臨時登入資料提供 AWS 資源的短期存取權，當您使用聯合或切換角色時，會自動建立。 AWS 建議您動態產生臨時登入資料，而不是使用長期存取金鑰。如需詳細資訊，請參閱《*IAM 使用者指南*》中的 [IAM 中的臨時安全憑證](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html)與[可與 IAM 搭配運作的AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。

## 轉送服務的存取工作階段 AWS WAF
<a name="security_iam_service-with-iam-principal-permissions"></a>

**支援轉寄存取工作階段 (FAS)：**是

 轉送存取工作階段 (FAS) 使用呼叫 的委託人許可 AWS 服務，並結合 AWS 服務 請求向下游服務提出請求。如需提出 FAS 請求時的政策詳細資訊，請參閱[轉發存取工作階段](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_forward_access_sessions.html)。

## 的服務角色 AWS WAF
<a name="security_iam_service-with-iam-roles-service"></a>

**支援服務角色：**是

 服務角色是服務擔任的 [IAM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)，可代您執行動作。IAM 管理員可以從 IAM 內建立、修改和刪除服務角色。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[建立角色以委派許可給 AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-service.html)。

**警告**  
變更服務角色的許可可能會中斷 AWS WAF 功能。只有在 AWS WAF 提供指引時，才能編輯服務角色。

## 的服務連結角色 AWS WAF
<a name="security_iam_service-with-iam-roles-service-linked"></a>

**支援服務連結角色：**是

 服務連結角色是連結至 的一種服務角色 AWS 服務。服務可以擔任代表您執行動作的角色。服務連結角色會出現在您的 中 AWS 帳戶 ，並由服務擁有。IAM 管理員可以檢視，但不能編輯服務連結角色的許可。

如需建立或管理 AWS WAF 服務連結角色的詳細資訊，請參閱 [使用 的服務連結角色 AWS WAF](using-service-linked-roles.md)。