

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

# 接收端點服務事件的提醒
<a name="create-notification-endpoint-service"></a>

您可以建立通知，接收與端點服務相關的特定事件的提醒。例如，當接受或拒絕連線請求時，您會收到電子郵件。

**Topics**
+ [

## 建立 SNS 通知
](#create-sns-notification-endpoint-service)
+ [

## 新增存取政策
](#add-access-policy-endpoint-service)
+ [

## 新增金鑰政策
](#add-key-policy-endpoint-service)

## 建立 SNS 通知
<a name="create-sns-notification-endpoint-service"></a>

使用以下步驟即可為通知建立 Amazon SNS 主題，並訂閱該主題。

**若要使用主控台建立端點服務的通知**

1. 在 [https://console.aws.amazon.com/vpc/](https://console.aws.amazon.com/vpc/) 開啟 Amazon VPC 主控台。

1. 在導覽窗格中，選擇 **Endpoints Services (端點服務)**。

1. 選取端點服務。

1. 在 **Notifications** (通知) 索引標籤中，選擇 **Create notification** (建立通知)。

1. 對於 **Notification ARN** (通知 ARN)，請選擇您建立的 SNS 主題的 ARN。

1. 若要訂閱事件，請從 **Events** (事件) 中選取。
   + **Connect** (連接) - 服務消費者建立的介面端點。這會將連線請求傳送至服務提供者。
   + **Accept** (接受) - 服務提供者接受連線請求。
   + **Reject** (拒絕) - 服務提供者拒絕連線請求。
   + **Delete** (刪除) - 服務消費者刪除介面端點。

1. 選擇 **Create notification (建立通知)**。

**若要使用命令列建立端點服務的通知**
+ [create-vpc-endpoint-connection-notification](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-vpc-endpoint-connection-notification.html) (AWS CLI)
+ [New-EC2VpcEndpointConnectionNotification](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2VpcEndpointConnectionNotification.html) (Tools for Windows PowerShell)

## 新增存取政策
<a name="add-access-policy-endpoint-service"></a>

將存取政策新增至 SNS 主題， AWS PrivateLink 允許 代表您發佈通知，如下所示。如需詳細資訊，請參閱[如何編輯我的 Amazon SNS 主題的存取政策？](https://repost.aws/knowledge-center/sns-edit-topic-access-policy) 使用 `aws:SourceArn` 和 `aws:SourceAccount` 全域條件金鑰，以防止發生[混淆代理人](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)的情況。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "vpce.amazonaws.com"
            },
            "Action": "SNS:Publish",
            "Resource": "arn:aws:sns:us-east-1:111111111111:topic-name",
            "Condition": {
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:ec2:us-east-1:111111111111:vpc-endpoint-service/service-id"
                },
                "StringEquals": {
                    "aws:SourceAccount": "111111111111"
                }
            }
        }
    ]
}
```

------

## 新增金鑰政策
<a name="add-key-policy-endpoint-service"></a>

如果您使用的是加密的 SNS 主題，KMS 金鑰的資源政策必須信任 AWS PrivateLink 才能呼叫 AWS KMS API 操作。金鑰政策範例如下。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "vpce.amazonaws.com"
            },
            "Action": [
                "kms:GenerateDataKey*",
                "kms:Decrypt"
            ],
            "Resource": "arn:aws:kms:us-east-1:111111111111:key/key-id",
            "Condition": {
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:ec2:us-east-1:111111111111:vpc-endpoint-service/service-id"
                },
                "StringEquals": {
                    "aws:SourceAccount": "111111111111"
                }
            }
        }
    ]
}
```

------