

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

# 連線至 EventBridge 中的私有 APIs
<a name="connection-private"></a>

您可以建立私有 HTTPS 端點的連線，以提供對 VPCs 或內部部署中資源的安全point-to-point網路存取，而不必周遊公有網際網路。例如，您可以建立連線來存取 Amazon Elastic Load Balancer 後方的 HTTPS 應用程式。

EventBridge 會使用在 VPC Lattice 中建立*的資源組態*，建立與私有 HTTPS 端點的連線。資源組態是邏輯物件，可識別資源並指定存取資源的方式和人員。若要在 EventBridge 中建立私有 API 的連線，您可以指定私有 API 的資源組態。如需詳細資訊，請參閱《*Amazon* [ VPC Lattice 使用者指南》中的 VPC Lattice 中的資源組態](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-configuration.html)。

然後EventBridge 會建立*資源關聯*，讓 EventBridge 能夠存取私有 API。如需詳細資訊，請參閱《*Amazon VPC Lattice 使用者指南*》中的[管理資源關聯](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-resource-config-associations)。

當 EventBridge 管理資源關聯時，它會使用您的登入資料建立關聯，因此您可以保留資源關聯操作的可見性。

![EventBridge 和 Step Functions 使用連線做為 HTTPS 端點的授權組態。](http://docs.aws.amazon.com/zh_tw/eventbridge/latest/userguide/images/connections-private-destination_eventbridge_conceptual.svg)


您可以建立連線來存取其他 AWS 帳戶中APIs。如需詳細資訊，請參閱[跨帳戶私有 APIs](connection-private-cross-region.md)。

## 連線至私有 APIs許可
<a name="connection-private-permissions"></a>

下列政策範例包含建立私有 API 連線所需的最低許可。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": [
                "vpc-lattice:CreateServiceNetworkResourceAssociation",
                "vpc-lattice:GetResourceConfiguration",
                "vpc-lattice:AssociateViaAWSService-EventsAndStates",
                "events:CreateConnection"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        }
    ]
}
```

------

下列政策範例包含更新私有 API 連線所需的最低許可。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": [
                "vpc-lattice:CreateServiceNetworkResourceAssociation",
                "vpc-lattice:GetResourceConfiguration",               
                "vpc-lattice:AssociateViaAWSService-EventsAndStates",
                "events:UpdateConnection"
            ],
            "Resource": [
                "*"
            ],
            "Effect": "Allow"
        }
    ]
}
```

------

## 監控私有 APIs連線的建立
<a name="connection-private-monitoring-create"></a>

當您建立私有 API 的連線時，會產生下列日誌：

在建立連線的帳戶中， AWS CloudTrail 會記錄`CreateServiceNetworkResourceAssociation`事件。

在此日誌中， `sourceIPAddress`、 `userAgent`和 `serviceNetworkIdentifier` 會設定為 EventBridge 服務主體 `events.amazonaws.com`。

```
{
  "eventTime": "2024-11-21T00:00:00Z",
  "eventSource": "vpc-lattice.amazonaws.com",
  "eventName": "CreateServiceNetworkResourceAssociation",
  "awsRegion": "{{region}}",
  "sourceIPAddress": "events.amazonaws.com", 
  "userAgent": "events.amazonaws.com",
  "requestParameters": {
    "x-amzn-vpc-lattice-association-source-arn": "***",
    "x-amzn-vpc-lattice-service-network-identifier": "***",
    "clientToken": "{{token}}",
    "serviceNetworkIdentifier": "events.amazonaws.com",
    "resourceConfigurationIdentifier": "arn:{{partition}}:vpc-lattice:{{region}}:{{account-id}}:resourceconfiguration/{{resource-configuration-id}}",
    "tags": {
        "ManagedByServiceAWSEventBridge": "{{account-id}}:{{connection-name}}"
    }
}
```

在包含私有 API 的帳戶中， 會 AWS CloudTrail 記錄`CreateServiceNetworkResourceAssociationBySharee`事件。

此日誌包含：
+ `callerAccountId`：建立連線 AWS 的帳戶
+ `accountId`：包含私有 API AWS 的帳戶。
+ `resource-configuration-arn`：私有 API 的 VPC Lattice 資源組態。

```
{
  "eventTime": "2024-11-21T06:31:42Z",
  "eventSource": "vpc-lattice.amazonaws.com",
  "eventName": "CreateServiceNetworkResourceAssociationBySharee",
  "awsRegion": "{{region}}",
  "sourceIPAddress": "vpc-lattice.amazonaws.com",
  "userAgent": "{{user-agent}}",
  "additionalEventData": {
      "callerAccountId": "{{consumer-account-id}}"
  },
  "resources": [
      {
          "accountId": "{{provider-account-id}}",
          "type": "AWS::VpcLattice::ServiceNetworkResourceAssociation",
          "ARN": "{{resource-configuration-arn}}"
      }
  ]
}
```

在與私有 APIs的跨帳戶連線的情況下，包含連線的帳戶將不會收到呼叫私有 API 的 AWS CloudTrail 或 VPC Lattice 日誌。

## 管理連線的服務網路資源關聯
<a name="connection-private-snra"></a>

當您為要連線的私有 API 指定 VPC Lattice 資源組態時，EventBridge 會透過在 VPC Lattice 資源組態與 EventBridge 服務擁有的 VPC Lattice 服務網路之間建立資源關聯來啟用連線。當 EventBridge 管理資源關聯時，它會使用您的登入資料建立關聯，因此您可以保留資源關聯的可見性。這表示您可以列出和描述資源關聯。

使用 [describe-connection](https://docs.aws.amazon.com/cli/latest/reference/events/describe-connection.html) 傳回包含資源組態和資源關聯的 Amazon Resource Name (ARNs) 的連線描述。

您無法刪除 EventBridge 建立的資源關聯。如果您刪除連線，EventBridge 會刪除任何對應的資源關聯。

如需詳細資訊，請參閱《*Amazon VPC Lattice 使用者指南*》中的[管理資源關聯](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-resource-config-associations)。

## 連線至內部部署私有 APIs
<a name="connection-private-on-prem"></a>

使用透過 AWS PrivateLink 和 VPC Lattice 存取 VPC 資源，您可以連線到內部部署私有 APIs。若要這麼做，您必須設定 VPC 與內部部署環境之間的網路路由。例如，您可以使用 [AWS Direct Connect](https://docs.aws.amazon.com/directconnect/latest/UserGuide/Welcome.html)或 [AWS Site-to-Site VPN](https://docs.aws.amazon.com/vpn/latest/s2svpn/VPC_VPN.html) 來建立此類路由。