

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

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

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

# 使用 AWS Shield 網路安全主管的服務連結角色
<a name="security_iam_nsd-with-iam-roles-service-linked"></a>

本節說明如何使用服務連結角色，讓 AWS Shield 網路安全主管存取您 AWS 帳戶中的資源。

AWS Shield 網路安全主管使用 AWS Identity and Access Management (IAM)[ 服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)。服務連結角色是直接連結至 AWS Shield 網路安全主管的唯一 IAM 角色類型。服務連結角色由 AWS Shield 網路安全主管預先定義，並包含該服務代表您呼叫其他 AWS 服務所需的所有許可。

服務連結角色可讓您更輕鬆地設定 AWS Shield 網路安全主管，因為您不必手動新增必要的許可。 AWS Shield 網路安全主管會定義其服務連結角色的許可，除非另有定義，否則只有 AWS Shield 網路安全主管可以擔任其角色。已定義的許可包括信任政策和許可政策。該許可政策無法連接至其他任何 IAM 實體。

請參閱 IAM 主控台中的完整服務連結角色：[NetworkSecurityDirectorServiceLinkedRolePolicy](https://console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/aws-service-role/NetworkSecurityDirectorServiceLinkedRolePolicy)。

您必須設定許可，IAM 實體 (如使用者、群組或角色) 才可建立、編輯或刪除服務連結角色。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[服務連結角色許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#service-linked-role-permissions)。

如需關於支援服務連結角色的其他服務的資訊，請參閱[可搭配 IAM 運作的AWS 服務](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)，並尋找 **Service-Linked Role** (服務連結角色) 欄顯示為 **Yes** (是) 的服務。選擇具有連結的**是**，以檢視該服務的服務連結角色文件。

## AWS Shield 網路安全主管的服務連結角色許可
<a name="slr-permissions"></a>

`NetworkSecurityDirectorServiceLinkedRolePolicy` 服務連結角色信任下列服務以擔任角色：
+ `network-director.amazonaws.com`

`NetworkSecurityDirectorServiceLinkedRolePolicy` 授予 AWS Shield 網路安全主管代表您存取和分析各種 AWS 資源和服務的許可。其中包含：
+ 從 Amazon EC2 資源擷取網路組態和安全性設定
+ 存取 CloudWatch 指標以分析網路流量模式
+ 收集負載平衡器和目標群組的相關資訊
+ 收集 AWS WAF 組態和規則
+ 存取 AWS Direct Connect 閘道資訊
+ 此外，如以下許可清單所述

下列清單適用於不支援縮小特定資源範圍的許可。其餘部分會針對指定的服務資源進行縮小範圍。

```
 {
  "Sid": "ResourceLevelPermissionNotSupported",
  "Effect": "Allow",
  "Action": [
    "cloudwatch:GetMetricData",
    "cloudwatch:GetMetricStatistics",
    "ec2:DescribeAvailabilityZones",
    "ec2:DescribeCustomerGateways",
    "ec2:DescribeInstances",
    "ec2:DescribeInternetGateways",
    "ec2:DescribeManagedPrefixLists",
    "ec2:DescribeNatGateways",
    "ec2:DescribeNetworkAcls",
    "ec2:DescribeNetworkInterfaces",
    "ec2:DescribePrefixLists",
    "ec2:DescribeRegions",
    "ec2:DescribeRouteTables",
    "ec2:DescribeSecurityGroups",
    "ec2:DescribeSubnets",
    "ec2:DescribeTransitGateways",
    "ec2:DescribeTransitGatewayVpcAttachments",
    "ec2:DescribeTransitGatewayAttachments",
    "ec2:DescribeTransitGatewayPeeringAttachments",
    "ec2:DescribeTransitGatewayRouteTables",
    "ec2:DescribeVpcEndpoints",
    "ec2:DescribeVpcEndpointServiceConfigurations",
    "ec2:DescribeVpcPeeringConnections",
    "ec2:DescribeVpcs",
    "ec2:DescribeVpnConnections",
    "ec2:DescribeVpnGateways",
    "ec2:GetTransitGatewayRouteTablePropagations",
    "ec2:GetManagedPrefixListEntries",
    "elasticloadbalancing:DescribeLoadBalancers",
    "elasticloadbalancing:DescribeTargetGroups",
    "elasticloadbalancing:DescribeTags",
    "elasticloadbalancing:DescribeListeners",
    "elasticloadbalancing:DescribeTargetHealth",
    "elasticloadbalancing:DescribeTargetGroupAttributes",
    "elasticloadbalancing:DescribeRules",
    "elasticloadbalancing:DescribeLoadBalancencerAttributes",
    "wafv2:ListWebACLs",
    "cloudfront:ListDistributions",
    "cloudfront:ListTagsForResource",
    "directconnect:DescribeDirectConnectGateways",
    "directconnect:DescribeVirtualInterfaces"
  ],
  "Resource": "*"
}
```

**`NetworkSecurityDirectorServiceLinkedRolePolicy` 服務連結角色許可**  
下列清單涵蓋`NetworkSecurityDirectorServiceLinkedRolePolicy`服務連結角色啟用的所有許可。

Amazon CloudFront

```
 {
  "Sid": "cloudfront",
  "Effect": "Allow",
  "Action": [
    "cloudfront:GetDistribution"
  ],
  "Resource": "arn:aws:cloudfront::*:distribution/*"
 }
```

AWS WAF

```
 {
  "Sid": "wafv2",
  "Effect": "Allow",
  "Action": [
    "wafv2:ListResourcesForWebACL",
    "wafv2:ListRuleGroups",
    "wafv2:ListAvailableManagedRuleGroups",
    "wafv2:GetRuleGroup",
    "wafv2:DescribeManagedRuleGroup",
    "wafv2:GetWebACL"
  ],
  "Resource": [
    "arn:aws:wafv2:*:*:global/rulegroup/*",
    "arn:aws:wafv2:*:*:regional/rulegroup/*",
    "arn:aws:wafv2:*:*:global/managedruleset/*",
    "arn:aws:wafv2:*:*:regional/managedruleset/*",
    "arn:aws:wafv2:*:*:global/webacl/*/*",
    "arn:aws:wafv2:*:*:regional/webacl/*/*",
    "arn:aws:apprunner:*:*:service/*",
    "arn:aws:cognito-idp:*:*:userpool/*",
    "arn:aws:ec2:*:*:verified-access-instance/*"
  ]
 }
```

AWS WAF 傳統

```
 {
  "Sid": "classicWaf",
  "Effect": "Allow",
  "Action": [
    "waf:ListWebACLs",
    "waf:GetWebACL"
  ],
  "Resource": [
    "arn:aws:waf::*:webacl/*",
    "arn:aws:waf-regional:*:*:webacl/*"
  ]
}
```

AWS Direct Connect

```
 {
  "Sid": "directconnect",
  "Effect": "Allow",
  "Action": [
    "directconnect:DescribeConnections",
    "directconnect:DescribeDirectConnectGatewayAssociations",
    "directconnect:DescribeDirectConnectGatewayAttachments",
    "directconnect:DescribeVirtualGateways"
  ],
  "Resource": [
    "arn:aws:directconnect::*:dx-gateway/*",
    "arn:aws:directconnect:*:*:dxcon/*",
    "arn:aws:directconnect:*:*:dxlag/*",
    "arn:aws:directconnect:*:*:dxvif/*"
  ]
 }
```

AWS Transit Gateway 路由

```
 {
  "Sid": "ec2Get",
  "Effect": "Allow",
  "Action": [
    "ec2:SearchTransitGatewayRoutes"
  ],
  "Resource": [
    "arn:aws:ec2:*:*:transit-gateway-route-table/*"
  ]
 }
```

AWS Network Firewall

```
 {
  "Sid": "networkFirewall",
  "Effect": "Allow",
  "Action": [
    "network-firewall:ListFirewalls",
    "network-firewall:ListFirewallPolicies",
    "network-firewall:ListRuleGroups",
    "network-firewall:DescribeFirewall",
    "network-firewall:DescribeFirewallPolicy",
    "network-firewall:DescribeRuleGroup"
  ],
  "Resource": [
    "arn:aws:network-firewall:*:*:*/*"
  ]
}
```

Amazon API Gateway

```
 {
   "Sid": "apiGatewayGetAPI",
   "Effect": "Allow",
   "Action": [
     "apigateway:GET"
   ],
  "Resource": [
    "arn:aws:apigateway:*::/restapis",
    "arn:aws:apigateway:*::/restapis/*",
    "arn:aws:apigateway:*::/apis",
    "arn:aws:apigateway:*::/apis/*",
    "arn:aws:apigateway:*::/tags/*",
    "arn:aws:apigateway:*::/vpclinks",
    "arn:aws:apigateway:*::/vpclinks/*"
  ]
 }
```

## 為 AWS Shield 網路安全主管建立服務連結角色
<a name="create-slr"></a>

您不需要手動建立服務連結角色，當您執行第一次網路分析時， AWS Shield 網路安全主管會為您建立服務連結角色。

若您刪除此服務連結角色，之後需要再次建立，您可以在帳戶中使用相同程序重新建立角色。當您啟用 AWS Shield 網路安全主管記錄時， AWS Shield 網路安全主管會再次為您建立服務連結角色。

## 編輯 AWS Shield 網路安全主管的服務連結角色
<a name="edit-slr"></a>

AWS Shield 網路安全主管不允許您編輯`NetworkSecurityDirectorServiceLinkedRolePolicy`服務連結角色。因為可能有各種實體會參考服務連結角色，所以您無法在建立角色之後變更其名稱。然而，您可使用 IAM 來編輯角色描述。如需詳細資訊，請參閱《*IAM 使用者指南*》中的[編輯服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#edit-service-linked-role)。

## 刪除 AWS Shield 網路安全主管的服務連結角色
<a name="delete-slr"></a>

若您不再使用需要服務連結角色的功能或服務，我們建議您刪除該角色。如此一來，您就沒有未主動監控或維護的未使用實體。然而，在手動刪除服務連結角色之前，您必須先清除資源。

這可保護您的 AWS Shield 網路安全主管資源，因為您不會不小心移除存取資源的許可。

**注意**  
如果您嘗試刪除資源時 AWS Shield ，網路安全主管服務正在使用 角色，則刪除可能會失敗。若此情況發生，請等待數分鐘後並再次嘗試操作。

**使用 IAM 手動刪除服務連結角色**

使用 IAM 主控台、IAM CLI 或 IAM API 刪除 `NetworkSecurityDirectorServiceLinkedRolePolicy` 服務連結角色。如需詳細資訊，請參閱《IAM 使用者指南》**中的[刪除服務連結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html#delete-service-linked-role)。

## AWS Shield 網路安全主管服務連結角色支援的 區域
<a name="slr-regions"></a>

**注意**  
AWS Shield 網路安全主管處於公開預覽版本中，可能會有所變更。

AWS Shield 網路安全主管支援在以下區域中使用服務連結角色，並且只能擷取這些區域中資源的資料。


| 區域名稱 | 區域 | 
| --- | --- | 
| 美國東部 (維吉尼亞北部) | us-east-1 | 
| Europe (Stockholm) | eu-north-1 | 
| 亞太區域 (泰國) | ap-southeast-7 | 
| 非洲 (開普敦) | ap-south-1 | 
| 美國東部 (俄亥俄) | us-east-2 | 
| 亞太地區 (馬來西亞) | ap-southeast-5 | 
| 亞太區域 (東京) | ap-northeast-1 | 
| 美國西部 (奧勒岡) | us-west-2 | 
| 歐洲 (西班牙) | eu-south-2 | 
| 歐洲 (愛爾蘭) | eu-west-1 | 
| 歐洲 (法蘭克福) | eu-central-1 | 
| 亞太地區 (香港) | ap-east-1 | 
| 亞太區域 (新加坡) | ap-southeast-1 | 
| 亞太區域 (雪梨) | ap-southeast-2 | 