

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

# 利用事件 AWS Ground Station 实现自动化
<a name="monitoring.automating-events"></a>

**注意**  
 本文档自始至终都使用 “事件” 一词。 CloudWatch 事件和 EventBridge 是相同的底层服务和 API。可以使用任何一种服务构建用于匹配传入事件并将事件路由至目标进行处理的规则。

 事件使您能够实现 AWS 服务自动化，并自动响应系统事件，例如应用程序可用性问题或资源更改。来自 AWS 服务的事件近乎实时地交付。您可以编写简单规则来指示您关注的事件，并指示要在事件匹配规则时执行的自动化操作。一些可以自动触发的操作包括：
+ 调用函数 AWS Lambda 
+ 调用 Amazon EC2 Run Command
+ 将事件中继到 Amazon Kinesis Data Streams
+ 激活 AWS Step Functions 状态机
+ 通知 Amazon SNS 主题或 Amazon SQS 队列

将事件与一起使用的一些示例 AWS Ground Station 包括：
+ 调用 Lambda 函数以根据事件状态自动启动和停止 Amazon EC2 实例。
+ 每当联络变更状态时发布到 Amazon SNS 主题。这些主题可以设置为在开始或结束联络时发送电子邮件通知。

 有关更多信息，请参阅 [Amazon Ev EventBridge ents 用户指南](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html)。

## AWS Ground Station 事件类型
<a name="gs-csc-event-types"></a>

**注意**  
 AWS Ground Station 生成的所有事件都将“aws.groundstation”作为“来源”的值。

AWS Ground Station 发出与状态更改相关的事件，以支持您自定义自动化。目前， AWS Ground Station 支持联系人状态更改事件、数据流端点组更改事件和星历状态更改事件。以下各节提供了有关每种类型的详细信息。

## 联系活动时间表
<a name="monitoring.automating-events.contact-timeline"></a>

AWS Ground Station 当您的联系人更改状态时，会发出事件。有关这些状态变化是什么以及各州本身含义的更多信息，请参阅[了解联系人生命周期](contacts.lifecycle.md)。您的联系人中使用的任何 dataflow 端点组都有一组独立的事件，这些事件也会发出。在同一时间段内，我们还会为您的 dataflow 端点组发出事件。在设置任务配置文件和数据流端点组时，您可以配置通过前和通过后事件的精确时间。

 下图显示了名义联系人及其关联的 Dataflow 端点组的状态和发出的事件。

 ![Diagram showing statuses and events for a nominal contact and its associated dataflow endpoint group.](http://docs.aws.amazon.com/zh_cn/ground-station/latest/ug/images/monitoring.automating-events.contact-timeline.png) 

 **Ground Station 联络状态变更** 

 如果您想在即将到来的联系人更改状态时执行特定操作，则可以设置规则来自动执行此操作。当您想要接收有关联络状态变更的通知时，这很有用。如果您想更改收到这些事件的时间，可以修改任务配置文件[ contactPrePassDurationSeconds](https://docs.aws.amazon.com/ground-station/latest/APIReference/API_UpdateMissionProfile.html#groundstation-UpdateMissionProfile-request-contactPrePassDurationSeconds)和[ contactPostPassDurationSeconds](https://docs.aws.amazon.com/ground-station/latest/APIReference/API_UpdateMissionProfile.html#groundstation-UpdateMissionProfile-request-contactPostPassDurationSeconds)。事件将发送到计划联络的区域。

 下面提供了一个示例事件。

```
{
    "version": "0",
    "id": "01234567-0123-0123",
    "account": "123456789012",
    "time": "2019-05-30T17:40:30Z",
    "region": "us-west-2",
    "source": "aws.groundstation",
    "resources": [
        "arn:aws:groundstation:us-west-2:123456789012:contact/11111111-1111-1111-1111-111111111111"
    ],
    "detailType": "Ground Station Contact State Change",
    "detail": {
        "contactId": "11111111-1111-1111-1111-111111111111",
        "groundstationId": "Ground Station 1",
        "missionProfileArn": "arn:aws:groundstation:us-west-2:123456789012:mission-profile/11111111-1111-1111-1111-111111111111",
        "satelliteArn": "arn:aws:groundstation::123456789012:satellite/11111111-1111-1111-1111-111111111111",
        "contactStatus": "PASS"
    }
}
```

 `contactStatus` 可使用的值在 [AWS Ground Station 联系人状态](contacts.lifecycle.md#contact-statuses) 中定义。

 **Ground Station 数据流终端节点组状态变更** 

 如果要在数据流终端节点组正用于接收数据时执行操作，则可以设置 规则以自动执行此操作。这将允许您执行不同的操作来响应数据流终端节点组状态的不断变更的状况。如果您想更改收到这些事件的时间，请使用具有不同[contactPrePassDurationSeconds](https://docs.aws.amazon.com/ground-station/latest/APIReference/API_CreateDataflowEndpointGroup.html#groundstation-CreateDataflowEndpointGroup-request-contactPrePassDurationSeconds)和的 dataflow 端点组。[contactPostPassDurationSeconds](https://docs.aws.amazon.com/ground-station/latest/APIReference/API_CreateDataflowEndpointGroup.html#groundstation-CreateDataflowEndpointGroup-request-contactPostPassDurationSeconds)此事件将发送到数据流终端节点组的区域。

 下面提供了一个示例。

```
{
    "version": "0",
    "id": "01234567-0123-0123",
    "account": "123456789012",
    "time": "2019-05-30T17:40:30Z",
    "region": "us-west-2",
    "source": "aws.groundstation",
    "resources": [
        "arn:aws:groundstation:us-west-2:123456789012:dataflow-endpoint-group/bad957a8-1d60-4c45-a92a-39febd98921d",
        "arn:aws:groundstation:us-west-2:123456789012:contact/98ddd10f-f2bc-479c-bf7d-55644737fb09",
        "arn:aws:groundstation:us-west-2:123456789012:mission-profile/c513c84c-eb40-4473-88a2-d482648c9234"
    ],
    "detailType": "Ground Station Dataflow Endpoint Group State Change",
    "detail": {
        "dataflowEndpointGroupId": "bad957a8-1d60-4c45-a92a-39febd98921d",
        "groundstationId": "Ground Station 1",
        "contactId": "98ddd10f-f2bc-479c-bf7d-55644737fb09",
        "dataflowEndpointGroupArn": "arn:aws:groundstation:us-west-2:680367718957:dataflow-endpoint-group/bad957a8-1d60-4c45-a92a-39febd98921d",
        "missionProfileArn": "arn:aws:groundstation:us-west-2:123456789012:mission-profile/c513c84c-eb40-4473-88a2-d482648c9234",
        "dataflowEndpointGroupState": "PREPASS"
    }
}
```

 `dataflowEndpointGroupState` 的可能状态包括 `PREPASS`、`PASS`、`POSTPASS` 和 `COMPLETED`。

## 星历事件
<a name="monitoring.automating-events.ephemeris"></a>

 **Ground Station Ephemeris 状态变更** 

 如果想要在星历变更状态时执行操作，则可设置规则以自动执行此操作。这允许您根据星历的变化状态执行不同的操作。例如，您可以在星历完成验证且现在已 `ENABLED` 时执行操作。此事件的通知将发送到上传星历的区域。

 下面提供了一个示例。

```
{
    "id": "7bf73129-1428-4cd3-a780-95db273d1602",
    "detail-type": "Ground Station Ephemeris State Change",
    "source": "aws.groundstation",
    "account": "123456789012",
    "time": "2019-12-03T21:29:54Z",
    "region": "us-west-2",
    "resources": [
        "arn:aws:groundstation::123456789012:satellite/10313191-c9d9-4ecb-a5f2-bc55cab050ec",
        "arn:aws:groundstation::123456789012:ephemeris/111111-cccc-bbbb-a555-bcccca005000"
    ],
    "detail": {
        "ephemerisStatus": "ENABLED",
        "ephemerisId": "111111-cccc-bbbb-a555-bcccca005000",
        "satelliteId": "10313191-c9d9-4ecb-a5f2-bc55cab050ec"
    }
}
```

 `ephemerisStatus` 的可能状态包括 `ENABLED`、`VALIDATING`、`INVALID`、`ERROR`、`DISABLED` 和 `EXPIRED` 