

**引入全新的主机体验 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)。服务相关角色是一种独特的 IAM 角色，直接链接到 AWS Shield 网络安全总监。服务相关角色由 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)并查找**服务相关角色**列中显示为**是**的服务。选择**是**和链接，查看该服务的服务关联角色文档。

## 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 network Security Director 支持在以下区域使用服务相关角色，并且只能在这些区域检索有关您的资源的数据。


| 区域名称 | Region | 
| --- | --- | 
| 美国东部（弗吉尼亚州北部） | us-east-1 | 
| 欧洲地区（斯德哥尔摩） | 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 | 