

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 如何 AWS Health 与 IAM 配合使用
<a name="security_iam_service-with-iam"></a>

在使用 IAM 管理访问权限之前 AWS Health，您应该了解哪些可用的 IAM 功能 AWS Health。要全面了解如何 AWS Health 和其他 AWS 服务与 IAM 配合使用，请参阅 IAM *用户指南中的与 IAM* [配合使用的AWS 服务](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html)。

**Topics**
+ [AWS Health 基于身份的策略](#security_iam_service-with-iam-id-based-policies)
+ [AWS Health 基于资源的政策](#security_iam_service-with-iam-resource-based-policies)
+ [基于 AWS Health 标签的授权](#security_iam_service-with-iam-tags)
+ [AWS Health IAM 角色](#security_iam_service-with-iam-roles)

## AWS Health 基于身份的策略
<a name="security_iam_service-with-iam-id-based-policies"></a>

使用 IAM 基于身份的策略，您可以指定允许或拒绝的操作和资源，以及指定在什么条件下允许或拒绝操作。 AWS Health 支持特定操作、资源和条件键。要了解在 JSON 策略中使用的所有元素，请参阅《IAM 用户指南》** 中的 [IAM JSON 策略元素参考](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html)。

### 操作
<a name="security_iam_service-with-iam-id-based-policies-actions"></a>

管理员可以使用 AWS JSON 策略来指定谁有权访问什么。也就是说，哪个**主体**可以对什么**资源**执行**操作**，以及在什么**条件**下执行。

JSON 策略的 `Action` 元素描述可用于在策略中允许或拒绝访问的操作。在策略中包含操作以授予执行关联操作的权限。

正在执行的策略操作在操作前 AWS Health 使用以下前缀:`health:`. 例如，要授予某人[DescribeEventDetails](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventDetails.html)通过 API 操作查看有关指定事件的详细信息的权限，您需要在策略中包含该`heath:DescribeEventDetails`操作。

策略声明必须包含`Action`或`NotAction`元素。 AWS Health 定义了自己的一组操作，这些操作描述了您可以使用此服务执行的任务。

要在单个语句中指定多项 操作，请使用逗号将它们隔开，如下所示。

```
"Action": [
      "health:action1",
      "health:action2"
```

您也可以使用通配符 (\$1) 指定多个操作。例如，要指定以单词 `Describe` 开头的所有操作，请包括以下操作。

```
"Action": "health:Describe*"
```



要查看 AWS Health 操作列表，请参阅 *IAM 用户指南 AWS Health*中的[定义操作](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awshealthapisandnotifications.html#awshealthapisandnotifications-actions-as-permissions)。

### 资源
<a name="security_iam_service-with-iam-id-based-policies-resources"></a>

管理员可以使用 AWS JSON 策略来指定谁有权访问什么。也就是说，哪个**主体**可以对什么**资源**执行**操作**，以及在什么**条件**下执行。

`Resource` JSON 策略元素指定要向其应用操作的一个或多个对象。作为最佳实践，请使用其 [Amazon 资源名称（ARN）](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html)指定资源。对于不支持资源级权限的操作，请使用通配符 (\$1) 指示语句应用于所有资源。

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



 AWS Health 事件采用以下亚马逊资源名称 (ARN) 格式。

```
arn:${Partition}:health:*::event/service/event-type-code/event-ID
```

例如，要在语句中指定 `EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456` 事件，请使用以下 ARN。

```
"Resource": "arn:aws:health:*::event/EC2/EC2_INSTANCE_RETIREMENT_SCHEDULED/EC2_INSTANCE_RETIREMENT_SCHEDULED_ABC123-DEF456"
```

要为属于特定账户的 Amazon EC2 指定所有 AWS Health 事件，请使用通配符 (\$1)。

```
"Resource": "arn:aws:health:*::event/EC2/*/*"
```

有关格式的更多信息 ARNs，请参阅 [Amazon 资源名称 (ARNs) 和 AWS 服务命名空间](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html)。

某些 AWS Health 操作无法对特定资源执行。在这些情况下，您必须使用通配符（\$1)。

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

AWS Health API 操作可能涉及多个资源。例如，该[DescribeEvents](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEvents.html)操作返回有关满足指定筛选条件的事件的信息。这意味着 IAM 用户必须具有查看此事件的权限。

要在单个语句中指定多个资源，请 ARNs 用逗号分隔。

```
"Resource": [
      "resource1",
      "resource2"
```

AWS Health 仅支持运行状况事件的资源级权限，且仅支持[DescribeAffectedEntities](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeAffectedEntities.html)和 [DescribeEventDetails](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventDetails.html)API 操作。有关更多信息，请参阅 [基于资源和基于操作的条件](security_iam_id-based-policy-examples.md#resource-action-based-conditions)。

要查看 AWS Health 资源类型及其列表 ARNs，请参阅 *IAM 用户指南 AWS Health*中的[由定义的资源](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awshealthapisandnotifications.html#awshealthapisandnotifications-resources-for-iam-policies)。要了解您可以在哪些操作中指定每个资源的 ARN，请参阅 [AWS Health定义的操作](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awshealthapisandnotifications.html#awshealthapisandnotifications-actions-as-permissions)。

### 条件键
<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 Health 定义自己的条件键集，还支持使用一些全局条件键。要查看所有 AWS 全局条件键，请参阅 *IAM 用户指南*中的[AWS 全局条件上下文密钥](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)。



[DescribeAffectedEntities](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeAffectedEntities.html)和 [DescribeEventDetails](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventDetails.html)API 操作支持`health:eventTypeCode`和`health:service`条件键。

要查看 AWS Health 条件键列表，请参阅 *IAM 用户指南 AWS Health*中的[条件密钥](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awshealthapisandnotifications.html#awshealthapisandnotifications-policy-keys)。要了解您可以使用条件键的操作和资源，请参阅[操作定义者 AWS Health](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awshealthapisandnotifications.html#awshealthapisandnotifications-actions-as-permissions)。

### 示例
<a name="security_iam_service-with-iam-id-based-policies-examples"></a>



要查看 AWS Health 基于身份的策略的示例，请参阅。[AWS Health 基于身份的策略示例](security_iam_id-based-policy-examples.md)

## AWS Health 基于资源的政策
<a name="security_iam_service-with-iam-resource-based-policies"></a>

基于资源的策略是 JSON 策略文档，用于指定委托人可以在哪些条件下对 AWS Health 资源执行哪些操作。 AWS Health 支持基于资源的健康事件权限策略。基于资源的策略允许您基于资源向其他账户授予使用权限。您也可以使用基于资源的策略来允许 AWS 服务访问您的 AWS Health 事件。

要启用跨账户访问，您可以将整个账户或其他账户中的 IAM 实体指定为[基于资源的策略中的委托人](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html)。将跨账户主体添加到基于资源的策略只是建立信任关系工作的一半而已。当委托人和资源位于不同的 AWS 账户中时，您还必须向委托人实体授予访问资源的权限。通过将基于身份的策略附加到实体以授予权限。但是，如果基于资源的策略向同一个账户中的主体授予访问权限，则不需要额外的基于身份的策略。有关更多信息，请参阅*《IAM 用户指南》* 中的 [IAM 角色与基于资源的策略有何不同](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_compare-resource-policies.html)。

AWS Health 仅支持针对[DescribeAffectedEntities](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeAffectedEntities.html)和 [DescribeEventDetails](https://docs.aws.amazon.com/health/latest/APIReference/API_DescribeEventDetails.html)API 操作的基于资源的策略。您可以在策略中指定这些操作，以定义哪些委托人实体（账户、用户、角色和联合用户）可以对 AWS Health 事件执行操作。

### 示例
<a name="security_iam_service-with-iam-resource-based-policies-examples"></a>



要查看 AWS Health 基于资源的策略的示例，请参阅[基于资源和基于操作的条件](security_iam_id-based-policy-examples.md#resource-action-based-conditions)。

## 基于 AWS Health 标签的授权
<a name="security_iam_service-with-iam-tags"></a>

AWS Health 不支持标记资源或基于标签控制访问权限。

## AWS Health IAM 角色
<a name="security_iam_service-with-iam-roles"></a>

I [AM 角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)是您的 AWS 账户中具有特定权限的实体。

### 将临时证书与 AWS Health
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

可以使用临时凭证进行联合身份验证登录，分派 IAM 角色或分派跨账户角色。您可以通过调用[AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html)或之类的 AWS STS API 操作来获取临时安全证书[GetFederationToken](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html)。

AWS Health 支持使用临时证书。

### 服务关联角色
<a name="security_iam_service-with-iam-roles-service-linked"></a>

[服务相关角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-linked-role)允许 AWS 服务访问其他服务中的资源以代表您完成操作。服务关联角色显示在 IAM 账户中，并归该服务所有。IAM 管理员可以查看但不能编辑服务关联角色的权限。

AWS Health 支持与服务相关的角色进行集成。 AWS Organizations服务相关角色命名为 `AWSServiceRoleForHealth_Organizations`。该角色附带的是 [Health\$1 OrganizationsServiceRolePolicy](https://console.aws.amazon.com//iam/home?#/policies/arn:aws:iam::aws:policy/aws-service-role/Health_OrganizationsServiceRolePolicy) AWS 托管策略。 AWS 托管策略 AWS Health 允许从组织中的其他 AWS 账户访问健康事件。

您可以使用该[EnableHealthServiceAccessForOrganization](https://docs.aws.amazon.com//health/latest/APIReference/API_EnableHealthServiceAccessForOrganization.html)操作在账户中创建服务相关角色。但是，如果要禁用此功能，则必须先调用该[DisableHealthServiceAccessForOrganization](https://docs.aws.amazon.com//health/latest/APIReference/API_DisableHealthServiceAccessForOrganization.html)操作。然后，您可以通过 IAM 控制台、IAM API 或 AWS Command Line Interface (AWS CLI) 删除该角色。有关更多信息，请参阅《 IAM 用户指南》**中的[使用服务相关角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/using-service-linked-roles.html)。

有关更多信息，请参阅 [跨账号聚合 AWS Health 事件](aggregate-events.md)。

### 服务角色
<a name="security_iam_service-with-iam-roles-service"></a>

此功能允许服务代表您担任[服务角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-role)。此角色允许服务访问其他服务中的资源以代表您完成操作。服务角色显示在 IAM 账户中，并归该账户所有。这意味着，IAM 管理员可以更改该角色的权限。但是，这样做可能会中断服务的功能。

AWS Health 不支持服务角色。