

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

# 通过 Amazon 接收来自 SaaS 合作伙伴的事件 EventBridge
<a name="eb-saas"></a>

为了能够从 SaaS 合作伙伴应用程序和服务接收*事件*，您需要合作伙伴提供的合作伙伴事件源。合作伙伴事件源是由合作伙伴创建的资源，您可以在该资源创建之后接受其作为事件源。要接受合作伙伴事件源，您可以创建自定义事件总线，并将其与合作伙伴事件源匹配。

![\[SaaS 合作伙伴向合作伙伴事件源发送事件，合作伙伴事件源将其发送到合作伙伴事件总线。\]](http://docs.aws.amazon.com/zh_cn/eventbridge/latest/userguide/images/bus-saas_eventbridge_conceptual.svg)


 以下视频介绍了 SaaS 与 EventBridge以下各项的集成：




**Topics**
+ [支持的 SaaS 合作伙伴集成](#eb-supported-integrations)
+ [将 Amazon 配置 EventBridge 为接收来自 SaaS 集成的事件](#eb-saas-integration)
+ [从亚马逊的 AWS Lambda 功能 URLs 中接收 SaaS 事件 EventBridge](eb-saas-furls.md)
+ [Salesforce在 Amazon 中接收来自的事件 EventBridge](eb-saas-salesforce.md)

## 支持的 SaaS 合作伙伴集成
<a name="eb-supported-integrations"></a>

EventBridge 支持以下 SaaS 合作伙伴集成：
+ [https://console.aws.amazon.com/events/#/partners/adobe.com?page=overview](https://console.aws.amazon.com/events/#/partners/adobe.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/appflow-salesforce.com?page=overview](https://console.aws.amazon.com/events/#/partners/appflow-salesforce.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/apptrail.com?page=overview](https://console.aws.amazon.com/events/#/partners/apptrail.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/atlan.com?page=overview](https://console.aws.amazon.com/events/#/partners/atlan.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/auth0.com?page=overview](https://console.aws.amazon.com/events/#/partners/auth0.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/authress.io?page=overview](https://console.aws.amazon.com/events/#/partners/authress.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/benchling.com?page=overview](https://console.aws.amazon.com/events/#/partners/benchling.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/bigcommerce.com?page=overview](https://console.aws.amazon.com/events/#/partners/bigcommerce.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/blitline.com?page=overview](https://console.aws.amazon.com/events/#/partners/blitline.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/buildkite.com?page=overview](https://console.aws.amazon.com/events/#/partners/buildkite.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/chargebee.com?page=overview](https://console.aws.amazon.com/events/#/partners/chargebee.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/checkout.com?page=overview](https://console.aws.amazon.com/events/#/partners/checkout.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/clevertap.com?page=overview](https://console.aws.amazon.com/events/#/partners/clevertap.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/cloudamqp.com?page=overview](https://console.aws.amazon.com/events/#/partners/cloudamqp.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/commercetools.com?page=overview](https://console.aws.amazon.com/events/#/partners/commercetools.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/datadoghq.com?page=overview](https://console.aws.amazon.com/events/#/partners/datadoghq.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/energysys.com?page=overview](https://console.aws.amazon.com/events/#/partners/energysys.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/epsagon.com?page=overview](https://console.aws.amazon.com/events/#/partners/epsagon.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/freshworks.com?page=overview](https://console.aws.amazon.com/events/#/partners/freshworks.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/genesys.com?page=overview](https://console.aws.amazon.com/events/#/partners/genesys.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/gladly.com?page=overview](https://console.aws.amazon.com/events/#/partners/gladly.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/gs2.io?page=overview](https://console.aws.amazon.com/events/#/partners/gs2.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/guidewire.com?page=overview](https://console.aws.amazon.com/events/#/partners/guidewire.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/hitachi-solutions.co.jp?page=overview](https://console.aws.amazon.com/events/#/partners/hitachi-solutions.co.jp?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/ilert.com?page=overview](https://console.aws.amazon.com/events/#/partners/ilert.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/jiraservicemanagement.com?page=overview](https://console.aws.amazon.com/events/#/partners/jiraservicemanagement.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/karte.io?page=overview](https://console.aws.amazon.com/events/#/partners/karte.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/kloudless.com?page=overview](https://console.aws.amazon.com/events/#/partners/kloudless.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/mackerel.io?page=overview](https://console.aws.amazon.com/events/#/partners/mackerel.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/mongodb.com?page=overview](https://console.aws.amazon.com/events/#/partners/mongodb.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/newrelic.com?page=overview](https://console.aws.amazon.com/events/#/partners/newrelic.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/nops.io?page=overview](https://console.aws.amazon.com/events/#/partners/nops.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/okta.com?page=overview](https://console.aws.amazon.com/events/#/partners/okta.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/onelogin.com?page=overview](https://console.aws.amazon.com/events/#/partners/onelogin.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/operata.com?page=overview](https://console.aws.amazon.com/events/#/partners/operata.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/opsgenie.com?page=overview](https://console.aws.amazon.com/events/#/partners/opsgenie.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/pagerduty.com?page=overview](https://console.aws.amazon.com/events/#/partners/pagerduty.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/payshield.com.au?page=overview](https://console.aws.amazon.com/events/#/partners/payshield.com.au?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/rhythmsoftware.com?page=overview](https://console.aws.amazon.com/events/#/partners/rhythmsoftware.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/rightsline.com?page=overview](https://console.aws.amazon.com/events/#/partners/rightsline.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/rootly.com?page=overview](https://console.aws.amazon.com/events/#/partners/rootly.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/saasus.io?page=overview](https://console.aws.amazon.com/events/#/partners/saasus.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/sailpoint.com?page=overview](https://console.aws.amazon.com/events/#/partners/sailpoint.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/scalr.com?page=overview](https://console.aws.amazon.com/events/#/partners/scalr.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/segment.com?page=overview](https://console.aws.amazon.com/events/#/partners/segment.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/shopify.com?page=overview](https://console.aws.amazon.com/events/#/partners/shopify.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/signalfx.com?page=overview](https://console.aws.amazon.com/events/#/partners/signalfx.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/site24x7.com?page=overview](https://console.aws.amazon.com/events/#/partners/site24x7.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/snowcatcloud.com?page=overview](https://console.aws.amazon.com/events/#/partners/snowcatcloud.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/snyk.io?page=overview](https://console.aws.amazon.com/events/#/partners/snyk.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/stax.io?page=overview](https://console.aws.amazon.com/events/#/partners/stax.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/stripe.com?page=overview](https://console.aws.amazon.com/events/#/partners/stripe.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/sugarcrm.com?page=overview](https://console.aws.amazon.com/events/#/partners/sugarcrm.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/symantec.com?page=overview](https://console.aws.amazon.com/events/#/partners/symantec.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/tealium.com?page=overview](https://console.aws.amazon.com/events/#/partners/tealium.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/thundra.io?page=overview](https://console.aws.amazon.com/events/#/partners/thundra.io?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/triggermesh.com?page=overview](https://console.aws.amazon.com/events/#/partners/triggermesh.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/whispir.com?page=overview](https://console.aws.amazon.com/events/#/partners/whispir.com?page=overview)
+ [https://console.aws.amazon.com/events/#/partners/zendesk.com?page=overview](https://console.aws.amazon.com/events/#/partners/zendesk.com?page=overview)
+ [Amazon Seller Partner API](https://console.aws.amazon.com/events/#/partners/sellingpartnerapi.amazon.com?page=overview) 

## 将 Amazon 配置 EventBridge 为接收来自 SaaS 集成的事件
<a name="eb-saas-integration"></a>

配置 EventBridge 接收合作伙伴事件包括两个主要步骤：
+ 创建合作伙伴事件源
+ 将该合作伙伴源关联到合作伙伴事件总线
**注意**  
合作伙伴向任何未与事件总线关联的合作伙伴事件源发布的事件都将立即被删除。这些事件不会在静止状态下持续下去。 EventBridge

**创建合作伙伴事件源（仅限控制台）**

1. 打开 Amazon EventBridge 控制台，网址为[https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/)。

1. 在导航窗格中，选择**合作伙伴事件源**。

1. 查找所需的合作伙伴，然后为该合作伙伴选择**设置**。

1. 要将您的账户 ID 复制到剪贴板，选择**复制**。

1. 在导航窗格中，选择**合作伙伴事件源**。

1. 转到合作伙伴的网站，并按照说明，使用您的账户 ID 创建合作伙伴事件源。您创建的事件源仅供您的账户使用。

**将合作伙伴源关联到合作伙伴事件总线（控制台）**

1. 在 EventBridge 控制台中，选择导航窗格中的**合作伙伴事件源**。

1. 选择合作伙伴事件源旁边的按钮，然后选择**与事件总线关联**。

   该事件源的状态从 `Pending` 更改为 `Active`，并更新事件总线的名称，以匹配伙伴事件源名称。您现在可以开始创建，以匹配来自该合作伙伴事件源的事件。

**将合作伙伴源关联到合作伙伴事件总线（AWS CLI）**
+ 使用 [https://docs.aws.amazon.com/cli/latest/reference/events/create-event-bus.html](https://docs.aws.amazon.com/cli/latest/reference/events/create-event-bus.html) 创建与合作伙伴事件源关联的合作伙伴事件总线。

  `name` 和 `event-source-name` 均应设置为合作伙伴事件源名称。

  例如：

  ```
  aws events create-event-bus \
      --name "aws.partner/saas-integration/name" \
      --event-source-name "aws.partner/saas-integration/name" \
      --region us-east-1
  ```

   EventBridge 创建事件总线后，您可以致电[https://docs.aws.amazon.com/cli/latest/reference/events/describe-event-source.html](https://docs.aws.amazon.com/cli/latest/reference/events/describe-event-source.html)以返回有关合作伙伴来源的详细信息。此时该合作伙伴源的 `State` 应为 `ACTIVE`。

  ```
  aws events describe-event-source
  --name "aws.partner/saas-integration/name"
  ```
**注意**  
对合作伙伴事件总线调用 [https://docs.aws.amazon.com/cli/latest/reference/events/put-permission.html](https://docs.aws.amazon.com/cli/latest/reference/events/put-permission.html) 时返回错误。仅允许与该合作伙伴事件总线关联的事件源的合作伙伴账户向其发送事件。

**将合作伙伴源关联到合作伙伴事件总线（CloudFormation）**

1. 创建使用合作伙伴事件源置备[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbus.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbus.html)资源的 CloudFormation 模板。

   `Name` 和 `EventSourceName` 均应设置为合作伙伴事件源名称。例如：

   ```
   AWSTemplateFormatVersion: 2010-09-09
   
   Description: 
      Cloudformation template to create Event Bus for receiving partner events
   
   Resources:
     ExamplePartnerEventBus:
       Type: AWS::Events::EventBus
       Properties:
         EventSourceName: 'aws.partner/saas-integration/name'
         Name: 'aws.partner/saas-integration/name'
   ```

1. 使用[https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html)或 CloudFormation 控制台根据模板创建堆栈。例如：

   ```
   aws cloudformation create-stack --stack-name eventbridge-saas --template-body file://template.yml --region us-east-1
   ```
**注意**  
在您的模板中为合作伙伴事件总线包含 [https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbuspolicy.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-eventbuspolicy.html) 资源将导致错误。仅允许与该合作伙伴事件总线关联的事件源的合作伙伴账户向其发送事件。

# 从亚马逊的 AWS Lambda 功能 URLs 中接收 SaaS 事件 EventBridge
<a name="eb-saas-furls"></a>

**注意**  
为了让我们的合作伙伴能够访问入站 Webhook，我们正在 AWS 您的账户中创建一个 Open Lambda，通过验证第三方合作伙伴发送的身份验证签名，在 Lambda 应用程序级别对其进行保护。请与您的安全团队一起检查此配置。有关更多信息，请参阅 [Lambda 函数 URLs的安全和身份验证模型](https://docs.aws.amazon.com/lambda/latest/dg/urls-auth.html#urls-auth-none)。

您的 Amazon EventBridge [事件总线](eb-event-bus.md)可以使用 CloudFormation 模板创建的[AWS Lambda 函数 URL](https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html) 来接收来自支持的 SaaS 提供商[的事件](eb-events.md)。使用函数 URLs，事件数据将发送到 Lambda 函数。然后，该函数将这些数据转换为事件，该事件可以由事件总线接收 EventBridge 并发送到事件总线进行处理。事件进入事件总线后，您可以使用规则来筛选事件，应用任何已配置的输入转换，然后将其路由到正确的目标。

**注意**  
创建 Lambda 函数 URLs 会增加您的每月费用。有关更多信息，请参阅[AWS Lambda 定价](https://aws.amazon.com/lambda/pricing)。

要设置与的连接 EventBridge，首先要选择要与之建立连接的 SaaS 提供商。然后，提供您与该提供商一起创建的*签名密钥*，然后选择要向其发送 EventBridge 事件的事件总线。最后，使用 CloudFormation 模板并创建完成连接所需的资源。

以下 SaaS 提供商目前可用于 EventBridge 使用 Lambda 函数： URLs
+ GitHub
+ Twilio

**Topics**
+ [步骤 1：创建 CloudFormation 堆栈](#create-gh-cfn-stack)
+ [步骤 2：创建 GitHub Webhook](#create-gh-webhook)
+ [设置 Twilio 连接](#furls-connection-twilio)
+ [更新 Webhook 密钥或身份验证令牌](#furls-update-secret)
+ [更新 Lambda 函数](#furls-update-function)
+ [可用事件类型](#furls-event-types)
+ [配额、错误代码和传送重试](#furls-quotas-errors)

## 步骤 1：创建 CloudFormation 堆栈
<a name="create-gh-cfn-stack"></a>

 首先，使用 Amazon EventBridge 控制台创建 CloudFormation 堆栈：

1. 打开亚马逊 EventBridge 控制台，网址为[https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/)。

1. 从导航窗格中选择**快速入门**。

1. 在 “**使用 Lambda URLs f 的入站 Webhook**” 下，**选择**入门。

1. 在 **GitHub** 下，选择**设置**。

1. 在**步骤 1：选择事件总线**下，从下拉列表中选择一个事件总线。此事件总线从您提供给 GitHub 的 Lambda 函数 URL 接收数据。您也可以选择**新建事件总线**来创建事件总线。

1. 在 “**步骤 2：使用进行设置**” 下 CloudFormation，选择 “**新建 GitHub webhook**”。

1. 选择**我确认我创建的入站 Webhook 可以公开访问。**然后选择**确认**。

1. 输入堆栈的名称。

1. 在参数下，验证是否列出了正确的事件总线，然后为 **GitHubWebhookSecret** 指定安全令牌。有关创建安全令牌的更多信息，请参阅 GitHub 文档中的[设置您的密钥令牌](https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks#setting-your-secret-token)。

1. 在**功能和转换**下，选择以下各项：
   + **我承认这 CloudFormation 可能会创建 IAM 资源。**
   + **我承认这 CloudFormation 可能会创建带有自定义名称的 IAM 资源。**
   + **我承认这 CloudFormation 可能需要以下能力：`CAPABILITY_AUTO_EXPAND`**

1. 选择**创建堆栈**。

## 步骤 2：创建 GitHub Webhook
<a name="create-gh-webhook"></a>

接下来，在 GitHub 中创建 Webhook。要完成此步骤，您需要安全令牌和在步骤 2 中创建的 Lambda 函数 URL。有关更多信息，请参阅 GitHub 文档中的[创建 Webhook](https://docs.github.com/en/developers/webhooks-and-events/webhooks/creating-webhooks)。

## 设置 Twilio 连接
<a name="furls-connection-twilio"></a>

### 步骤 1：查找您的 Twilio 身份验证令牌
<a name="create-twilio-secret"></a>

要在Twilio和之间建立连接 EventBridge，请先Twilio使用Twilio账户的身份验证令牌或密钥将连接设置为。有关更多信息，请参阅 Twilio 文档中的[身份验证令牌及其更改方法](https://support.twilio.com/hc/en-us/articles/223136027-Auth-Tokens-and-How-to-Change-Them)。

### 步骤 2：创建 CloudFormation 堆栈
<a name="create-twilio-cfn-stack"></a>

1. 打开亚马逊 EventBridge 控制台，网址为[https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/)。

1. 在导航窗格中选择**快速入门**。

1. 在 “**使用 Lambda URLs f 的入站 Webhook**” 下，**选择**入门。

1. 在 **Twilio** 下，选择**设置**。

1. 在**步骤 1：选择事件总线**下，从下拉列表中选择一个事件总线。此事件总线从您提供给 Twilio 的 Lambda 函数 URL 接收数据。您也可以选择**新建事件总线**来创建事件总线。

1. 在 “**步骤 2：使用进行设置**” 下 CloudFormation，选择 “**新建 Twilio webhook**”。

1. 选择**我确认我创建的入站 Webhook 可以公开访问。**然后选择**确认**。

1. 输入堆栈的名称。

1. 在参数下，验证是否列出了正确的事件总线，然后输入您在步骤 1 中创建的 **TwilioWebhookSecret**。

1. 在**功能和转换**下，选择以下各项：
   + **我承认这 CloudFormation 可能会创建 IAM 资源。**
   + **我承认这 CloudFormation 可能会创建带有自定义名称的 IAM 资源。**
   + **我承认这 CloudFormation 可能需要以下功能：CAPABILITY\$1AUTO\$1EXPAND**

1. 选择**创建堆栈**。

### 步骤 3：创建 Twilio Webhook
<a name="create-twilio-webhook"></a>

设置 Lambda 函数 URL 后，您需要将其提供给 Twilio，以便发送事件数据。有关更多信息，请参阅 Twilio 文档中的[使用 Twilio 配置您的公共 URL](https://www.twilio.com/docs/usage/webhooks/getting-started-twilio-webhooks#configure-your-public-url-with-twilio)。

## 更新 Webhook 密钥或身份验证令牌
<a name="furls-update-secret"></a>

### 更新 GitHub 密钥
<a name="update-gh-secret"></a>

**注意**  
GitHub 不支持同时拥有两个密钥。当 CloudFormation 堆栈中的GitHub密钥和密钥不同步时，您可能会遇到资源停机情况。 GitHub由于签名不正确，在密钥不同步时发送的消息将失败。等到GitHub和 CloudFormation 密钥同步，然后重试。

1. 新建 GitHub 密钥。有关更多信息，请参阅 GitHub 文档中[加密机密](https://docs.github.com/en/actions/security-guides/encrypted-secrets)。

1. 在 [https://console.aws.amazon.com/cloudformat](https://console.aws.amazon.com/cloudformation/) ion 上打开 CloudFormation 控制台。

1. 从导航窗格中，选择**堆栈**。

1. 为 Webhook 选择堆栈，其中包含要更新的密钥。

1. 选择**更新**。

1. 确保选中**使用当前模板**，然后选择**下一步**。

1. 在下方 **GitHubWebhookSecret**，清除 “**使用现有值**”，输入您在步骤 1 中创建的新GitHub密钥，然后选择**下一**步。

1. 选择**下一步**。

1. 选择**更新堆栈**。

密钥传播可能最多需要一个小时。为了缩短停机时间，您可以刷新 Lambda 执行上下文。

### 更新 Twilio 密钥
<a name="update-twilio-secret"></a>

**注意**  
Twilio 不支持同时拥有两个密钥。当 CloudFormation 堆栈中的Twilio密钥和密钥不同步时，您可能会遇到资源停机情况。 Twilio由于签名不正确，在密钥不同步时发送的消息将失败。等到Twilio和 CloudFormation 密钥同步，然后重试。

1. 新建 Twilio 密钥。有关更多信息，请参阅 Twilio 文档中的[身份验证令牌及其更改方法](https://support.twilio.com/hc/en-us/articles/223136027-Auth-Tokens-and-How-to-Change-Them)。

1. 在 [https://console.aws.amazon.com/cloudformat](https://console.aws.amazon.com/cloudformation/) ion 上打开 CloudFormation 控制台。

1. 从导航窗格中，选择**堆栈**。

1. 为 Webhook 选择堆栈，其中包含要更新的密钥。

1. 选择**更新**。

1. 确保选中**使用当前模板**，然后选择**下一步**。

1. 在下方 **TwilioWebhookSecret**，清除 “**使用现有值**”，输入您在步骤 1 中创建的新Twilio密钥，然后选择**下一**步。

1. 选择**下一步**。

1. 选择**更新堆栈**。

密钥传播可能最多需要一个小时。为了缩短停机时间，您可以刷新 Lambda 执行上下文。

## 更新 Lambda 函数
<a name="furls-update-function"></a>

 CloudFormation 堆栈创建的 Lambda 函数创建基本的 webhook。如果您想针对特定用例（例如自定义日志）自定义 Lambda 函数，请使用 CloudFormation 控制台访问该函数，然后使用 Lambda 控制台更新 Lambda 函数代码。

**访问 Lambda 函数**

1. 在 [https://console.aws.amazon.com/cloudformat](https://console.aws.amazon.com/cloudformation/) ion 上打开 CloudFormation 控制台。

1. 从导航窗格中，选择**堆栈**。

1. 为 Webhook 选择堆栈，其中包含要更新的 Lambda 函数。

1. 选择**资源**选项卡。

1. 要在 Lambda 控制台中打开 Lambda 函数，请在**物理 ID** 下选择 Lambda 函数的 ID。

现在您已获得了 Lambda 函数，请使用 Lambda 控制台更新函数代码。

**更新 Lambda 函数代码**

1. 在**操作**下，选择**导出函数**。

1. 选择**下载部署包**并将文件保存到您的计算机中。

1. 解压缩部署包 .zip 文件，更新 `app.py` 文件，然后压缩更新后的部署包，确保包含原始 .zip 文件中的所有文件。

1. 在 Lambda 控制台中，选择**代码**选项卡。

1. 在 **Code source**（代码源）下，选择 **Upload from**（上载自）。

1. 选择 **.zip file** (.zip 文件)，然后选择 **Upload file** (上载文件)。

   1. 在文件选择器中，选择您更新的文件，然后依次选择**打开**和**保存**。

1. 在**操作**下，选择**发布新版本**。

## 可用事件类型
<a name="furls-event-types"></a>

事件总线目前支持以下 CloudFormation 事件类型：
+ **GitHub**— 支持[所有事件类型](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads)。
+ **Twilio** - 支持[事件后 Webhook](https://www.twilio.com/docs/chat/webhook-events)。

## 配额、错误代码和传送重试
<a name="furls-quotas-errors"></a>

### 配额
<a name="furls-quotas"></a>

Webhook 的传入请求数量受底层 AWS 服务的限制。下表包括相关的配额。


| 服务 | 配额 | 
| --- | --- | 
|  AWS Lambda  |  默认：10 个并发执行 有关配额的更多信息（包括如何请求增加配额），请参阅 [Lambda 配额](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html)。  | 
|  AWS Secrets Manager  |  默认：每秒 5,000 个请求 有关配额的更多信息（包括如何请求增加配额），请参阅 [AWS Secrets Manager 配额](https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_limits.html)。 使用 [AWS Secrets Manager Python 缓存客户端](https://github.com/aws/aws-secretsmanager-caching-python#cache-configuration)可以最大限度地减少每秒的请求数。  | 
|  Amazon EventBridge  |   PutEvents 操作的最大条目大小为 1 MB。 EventBridge 强制执行基于区域的费率配额。有关更多信息，请参阅 [EventBridge 活动总线配额](eb-quota.md#eb-limits)。  | 

### 错误代码
<a name="furls-errors"></a>

发生错误时，每项 AWS 服务都会返回特定的错误代码。下表包括相关的错误代码。


| 服务 | 错误代码 | 说明 | 
| --- | --- | --- | 
|  AWS Lambda  |  429 “” TooManyRequestsExption  |  超出并发执行配额。  | 
|  AWS Secrets Manager  |  500 “Internal Server Error”  |  超出每秒请求数配额。  | 
|  Amazon EventBridge  |  500 “Internal Server Error”  |  超出该区域的费率配额。  | 

### 活动重新传送
<a name="furls-redelivery"></a>

发生错误时，您可以重试传送受影响的事件。每个 SaaS 提供商都有不同的重试步骤。

#### GitHub
<a name="furls-redelivery-github"></a>

可使用 GitHub Webhook API 检查任何 Webhook 调用的传送状态，并在需要时重新传送事件。有关更多信息，请参阅 GitHub 文档：
+ **组织** - [为组织 Webhook 重新传送](https://docs.github.com/en/rest/orgs/webhooks#redeliver-a-delivery-for-an-organization-webhook)
+ **存储库** - [为存储库 Webhook 重新传送](https://docs.github.com/en/rest/webhooks/repo-deliveries#redeliver-a-delivery-for-a-repository-webhook)
+ **应用** - [为应用 Webhook 重新传送](https://docs.github.com/en/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook)

#### Twilio
<a name="furls-redelivery-twilio"></a>

Twilio 用户可以使用连接覆盖来自定义事件重试选项。有关更多信息，请参阅 Twilio 文档中的 [Webhook（HTTP 回调）：连接覆盖](https://www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides)。

# Salesforce在 Amazon 中接收来自的事件 EventBridge
<a name="eb-saas-salesforce"></a>

您可以通过以下方式使用 Amazon EventBridge 接收来自Salesforce以下[的事件](eb-events.md)：
+ 使用Salesforce's事件总线中继功能直接在 EventBridge 合作伙伴事件总线上接收事件。
+ 通过在 A [mazon AppFlow](https://aws.amazon.com/appflow/) 中配置Salesforce用作数据源的流程。 AppFlow 然后，Amazon 使用[合作伙伴事件总线向发送Salesforce事件](eb-saas.md)。 EventBridge 

您可以使用 API 目标将事件信息发送到 Salesforce。事件发送到 Salesforce 后，即可通过[流](https://help.salesforce.com/s/articleView?id=flow.htm)或 [Apex 触发器](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers.htm)进行处理。有关设置 Salesforce API 目标的更多信息，请参阅 [教程：从 Amazon EventBridge 向 Salesforce 发送事件](eb-tutorial-salesforce.md)。

**Topics**
+ [使用事件总线中继从 Salesforce 接收事件](#eb-saas-salesforce-relay)
+ [Salesforce通过使用 Amazon 接收事件 AppFlow](#eb-saas-salesforce-appflow)

## 使用事件总线中继从 Salesforce 接收事件
<a name="eb-saas-salesforce-relay"></a>

### 步骤 1：设置Salesforce事件总线中继和 EventBridge 合作伙伴事件源
<a name="eb-set-up-relay"></a>

在上创建事件中继配置时Salesforce，Salesforce会创建一个处于待处理状态的合作伙伴事件源。 EventBridge 

**配置 Salesforce 事件总线中继**

1. [设置 REST API 工具](https://resources.docs.salesforce.com/rel1/doc/en-us/static/pdf/Salesforce_Event_Bus_Relay_Pilot.pdf#h.z63eim1tqkm3)

1. [（可选）定义平台事件](https://resources.docs.salesforce.com/rel1/doc/en-us/static/pdf/Salesforce_Event_Bus_Relay_Pilot.pdf#h.2m5t2i52o23m)

1. [为自定义平台活动创建频道](https://resources.docs.salesforce.com/rel1/doc/en-us/static/pdf/Salesforce_Event_Bus_Relay_Pilot.pdf#h.s0spl5puf9d0)

1. [创建频道成员，以关联自定义平台事件](https://resources.docs.salesforce.com/rel1/doc/en-us/static/pdf/Salesforce_Event_Bus_Relay_Pilot.pdf#h.rdhi4awp8cvv)

1. [创建命名凭证](https://resources.docs.salesforce.com/rel1/doc/en-us/static/pdf/Salesforce_Event_Bus_Relay_Pilot.pdf#h.etec44jyv3og)

1. [创建事件中继配置](https://resources.docs.salesforce.com/rel1/doc/en-us/static/pdf/Salesforce_Event_Bus_Relay_Pilot.pdf#h.43rfyeehz0w5)

### 第 2 步：在 EventBridge 控制台中激活Salesforce合作伙伴事件源并启动事件中继
<a name="eb-salesforce-activate-source"></a>

1. 在 EventBridge 控制台中打开[合作伙伴事件源](https://console.aws.amazon.com/events/home?#/partners)页面。

1. 选择您在步骤 1 中创建的 Salesforce 合作伙伴事件源。

1. 选择**与事件总线关联**。

1. 验证合作伙伴事件总线的名称。

1. 选择**关联**。

1. [启动事件中继](https://resources.docs.salesforce.com/rel1/doc/en-us/static/pdf/Salesforce_Event_Bus_Relay_Pilot.pdf#h.t01b3xp87vhu)

现在，您已经设置并启动了事件总线中继并配置了合作伙伴事件源[，您可以创建一个对事件做出反应的EventBridge 规则](eb-create-rule-visual.md)，以筛选数据并将其发送到[目标](eb-targets.md)。

## Salesforce通过使用 Amazon 接收事件 AppFlow
<a name="eb-saas-salesforce-appflow"></a>

Amazon AppFlow 将活动封装在活动信封Salesforce中。 EventBridge 以下示例显示了 EventBridge 合作伙伴Salesforce事件总线接收的事件。

```
{
    "version": "0",
    "id": "5c42b99e-e005-43b3-c744-07990c50d2cc",
    "detail-type": "AccountChangeEvent",
    "source": "aws.partner/appflow.test/salesforce.com/364228160620/CustomSF-Source-Final",
    "account": "000000000",
    "time": "2020-08-20T18:25:51Z",
    "region": "us-west-2",
    "resources": [],
    "detail": {
        "ChangeEventHeader": {
            "commitNumber": 248197218874,
            "commitUser": "0056g000003XW7AAAW",
            "sequenceNumber": 1,
            "entityName": "Account",
            "changeType": "UPDATE",
            "changedFields": [
                "LastModifiedDate",
                "Region__c"
            ],
            "changeOrigin": "com/salesforce/api/soap/49.0;client=SfdcInternalAPI/",
            "transactionKey": "000035af-b239-0581-9f14-461e4187de11",
            "commitTimestamp": 1597947935000,
            "recordIds": [
                "0016g00000MLhLeAAL"
            ]
        },
        "LastModifiedDate": "2020-08-20T18:25:35.000Z",
        "Region__c": "America"
    }
}
```

### 步骤 1： AppFlow 将 Amazon 配置Salesforce为合作伙伴事件源
<a name="eb-configure-appflow"></a>

要向发送事件 EventBridge，您首先需要 AppFlow 将 Amazon 配置Salesforce为合作伙伴事件源。

1. 在 [Amazon AppFlow 控制台](https://console.aws.amazon.com/appflow/)中，选择**创建流程**。

1. 在**流详细信息**部分，在**流名称**中输入流的名称。

1. （可选）输入流的描述，然后选择**下一步**。

1. 在**源详细信息**下，从**源名称**下拉列表中选择 *Salesforce*，然后选择**连接**以创建新连接。

1. 在**连接到 Salesforce** 对话框中，为 Salesforce 环境选择**生产**或**沙盒**。

1. 在**连接名称**字段中，输入连接的唯一名称，然后选择**继续**。

1. 在 Salesforce 对话框中，执行以下操作：

   1. 输入您的 Salesforce 登录凭证，登录 Salesforce。

   1. 为 Amazon AppFlow 要处理的数据类型选择Salesforce事件。

1. 在**选择Salesforce事件**下拉列表中，选择要发送到的事件类型 EventBridge。

1. 对于目的地，请选择 **Amazon EventBridge**。

1. 选择**创建新的合作伙伴事件源**。

1. （可选）为合作伙伴事件源指定唯一的后缀。

1. 选择**生成合作伙伴事件源**。

1. 选择一个 Amazon S3 存储桶来存储大于 1 MB 的事件负载文件。

1. 在**流触发器**部分，确保选中**按事件运行流**。此设置可确保在发生新的 Salesforce 事件时执行流。

1. 选择**下一步**。

1. 要进行字段映射，请选择**直接映射所有字段**。也可以从**源字段名称**列表中选择您感兴趣的字段。

   有关字段映射的更多信息，请参阅[映射数据字段](https://docs.aws.amazon.com//appflow/latest/userguide/getting-started.html#map-fields)。

1. 选择**下一步**。

1. （可选）在 Amazon 中为数据字段配置筛选条件 AppFlow。

1. 选择**下一步**。

1. 检查设置，然后选择**创建流**。

配置流程后，Amazon AppFlow 会创建一个新的合作伙伴事件源，然后您需要将其与账户中的合作伙伴事件总线相关联。

### 步骤 2：配置 EventBridge 为接收Salesforce事件
<a name="eb-salesforce-events"></a>

在按照本节的说明进行操作之前，请确保已配置从以目标 EventBridge 为目标Salesforce的事件触发的 Amazon AppFlow 流程。

**配置 EventBridge 为接收Salesforce事件**

1. 在 EventBridge 控制台中打开[合作伙伴事件源](https://console.aws.amazon.com/events/home?#/partners)页面。

1. 选择您在步骤 1 中创建的 Salesforce 合作伙伴事件源。

1. 选择**与事件总线关联**。

1. 验证合作伙伴事件总线的名称。

1. 选择**关联**。

1. 在 Amazon AppFlow 控制台中，打开您创建的流程，然后选择**激活流程**。

1. 在 EventBridge 控制台中打开[规则](https://console.aws.amazon.com/events/home?#/rules)页面。

1. 选择 **Create rule**（创建规则）。

1. 为规则输入唯一名称。

1. 在**定义模式**部分，选择**事件模式**。

1. 在**事件匹配模式**下，选择**服务提供的预定义模式**。

1. 在**服务提供商**部分，选择**所有事件**。

1. 在**选择事件总线**中，选择**自定义或合作伙伴事件总线**。

1. 选择您与 Amazon AppFlow 合作伙伴事件源关联的事件总线。

1. **在 “选择目标”** 中，选择规则运行时要执行的 AWS 服务。一个规则最多可以有五个目标。

1. 选择**创建**。

目标服务会接收为您的账户配置的所有 Salesforce 事件。要筛选事件或将某些事件发送到不同的目标，您可以使用[事件模式中基于内容的筛选](eb-create-pattern.md#eb-event-patterns-content-based-filtering)。

**注意**  
对于大于 1 MB 的事件，Amazon AppFlow 不会将完整事件发送至 EventBridge。相反，Amazon AppFlow 会将事件放入您账户的 S3 存储桶中，然后向发送一个 EventBridge 带有指向 Amazon S3 存储桶指针的事件。您可以使用此指针从桶中获取完整事件。