

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

# AWS CloudTrail 搭配界面 VPC 端點使用
<a name="cloudtrail-and-interface-VPC"></a>

如果您使用 Amazon Virtual Private Cloud (Amazon VPC) 託管 AWS 資源，您可以在 VPC 與 之間建立私有連線 AWS CloudTrail。您可以使用此連線來啟用 CloudTrail 不用透過公有網際網路在 VPC 與您的資源進行通訊。

Amazon VPC 是一項 AWS 服務，可用來在您定義的虛擬網路中啟動 AWS 資源。您可利用 VPC 來控制您的網路設定，例如 IP 地址範圍、子網路、路由表和網路閘道。透過 VPC 端點，VPC 和 AWS 服務之間的路由由 AWS 網路處理，您可以使用 IAM 政策來控制對服務資源的存取。

若要將您的 VPC 連接到 CloudTrail，請定義 CloudTrail 的 *VPC 端點界面*。界面端點是具有私有 IP 地址的彈性網路界面，可做為目的地為支援 AWS 服務之流量的進入點。端點能為 CloudTrail 提供可靠、可擴展性的連線，無須使用網際網路閘道、網路位址轉譯 (NAT) 執行個體或 VPN 連接。如需詳細資訊，請參閱《Amazon VPC 使用者指南》**中的[什麼是 Amazon VPC](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html)。

介面 VPC 端點採用 AWS PrivateLink 技術，這項 AWS 技術可使用具有私有 IP 地址的彈性網路介面，在 AWS 服務之間進行私有通訊。如需詳細資訊，請參閱 [AWS PrivateLink](https://aws.amazon.com/privatelink/)。

以下章節適用於 Amazon VPC 的使用者。如需詳細資訊，請參閱《Amazon VPC 使用者指南》**中的 [Amazon VPC 入門](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-getting-started.html)。

**Topics**
+ [大區 (Regions)](#cloudtrail-interface-VPC-availability)
+ [為 CloudTrail 建立 VPC 端點](#create-VPC-endpoint-for-CloudTrail)
+ [建立 CloudTrail 的 VPC 端點政策](#create-VPC-endpoint-policy)
+ [共用子網路](#shared-subnet-cloudtrail)

## 大區 (Regions)
<a name="cloudtrail-interface-VPC-availability"></a>

AWS CloudTrail 在支援 CloudTrail 的所有 AWS 區域 中支援 VPC 端點和 VPC 端點政策。

## 為 CloudTrail 建立 VPC 端點
<a name="create-VPC-endpoint-for-CloudTrail"></a>

若要以 VPC 開始使用 CloudTrail，請建立 CloudTrail 的 VPC 端點界面。如需詳細資訊，請參閱[《Amazon VPC 使用者指南》中的 AWS 服務 使用介面 VPC 端點存取](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#create-interface-endpoint.html) 。 **

您不需要變更 CloudTrail 的設定。CloudTrail AWS 服務 使用公有端點或私有介面 VPC 端點呼叫其他 ，以使用中者為準。

## 建立 CloudTrail 的 VPC 端點政策
<a name="create-VPC-endpoint-policy"></a>



VPC 端點政策是您可以連接到介面 VPC 端點的 IAM 資源。預設端點政策可讓您透過介面 VPC 端點完整存取 CloudTrail APIs。若要控制從您的 VPC 授予 CloudTrail 的存取權，請將自訂端點政策連接至介面 VPC 端點。

端點政策會指定以下資訊：
+ 可執行動作 (AWS 帳戶、IAM 使用者和 IAM 角色) 的主體。
+ 可執行的動作。
+ 可供執行動作的資源。

如需 VPC 端點政策的詳細資訊，包括如何更新政策，請參閱《*Amazon VPC 使用者指南*》中的[使用 VPC 端點控制對 服務的存取](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-access.html)。

以下是 CloudTrail 的自訂 VPC 端點政策範例。

**Topics**
+ [範例：允許所有 CloudTrail 動作](#create-VPC-endpoint-policy-example1)
+ [範例：允許特定的 CloudTrail 動作](#create-VPC-endpoint-policy-example2)
+ [範例：拒絕所有 CloudTrail 動作](#create-VPC-endpoint-policy-example3)
+ [範例：拒絕特定 CloudTrail 動作](#create-VPC-endpoint-policy-example4)
+ [範例：允許來自特定 VPC 的所有 CloudTrail 動作](#create-VPC-endpoint-policy-example5)
+ [範例：允許來自特定 VPC 端點的所有 CloudTrail 動作](#create-VPC-endpoint-policy-example6)

### 範例：允許所有 CloudTrail 動作
<a name="create-VPC-endpoint-policy-example1"></a>

下列範例 VPC 端點政策會授予所有資源上所有主體所有 CloudTrail 動作的存取權。

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

****  

```
{
     "Version":"2012-10-17",		 	 	 
     "Statement": [
         {
             "Action": "cloudtrail:*",
             "Effect": "Allow",
             "Resource": "*",
             "Principal": "*"
         }
     ]
}
```

------

### 範例：允許特定的 CloudTrail 動作
<a name="create-VPC-endpoint-policy-example2"></a>

下列範例 VPC 端點政策授予在所有資源上執行 `cloudtrail:ListTrails`和 `cloudtrail:ListEventDataStores`動作的存取權。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": ["cloudtrail:ListTrails", "cloudtrail:ListEventDataStores"],
            "Effect": "Allow",
            "Principal": "*",
            "Resource": "*"
        }
    ]
}
```

------

### 範例：拒絕所有 CloudTrail 動作
<a name="create-VPC-endpoint-policy-example3"></a>

下列範例 VPC 端點政策拒絕存取所有資源上所有主體的所有 CloudTrail 動作。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": "cloudtrail:*",
            "Effect": "Deny",
            "Principal": "*",
            "Resource": "*"
        }
    ]
}
```

------

### 範例：拒絕特定 CloudTrail 動作
<a name="create-VPC-endpoint-policy-example4"></a>

下列範例 VPC 端點政策會拒絕所有資源上所有主體的 `cloudtrail:CreateTrail`和 `cloudtrail:CreateEventDataStore`動作。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Action": ["cloudtrail:CreateTrail", "cloudtrail:CreateEventDataStore"],
            "Effect": "Deny",
            "Principal": "*",
            "Resource": "*"
        }
    ]
}
```

------

### 範例：允許來自特定 VPC 的所有 CloudTrail 動作
<a name="create-VPC-endpoint-policy-example5"></a>

下列範例 VPC 端點政策授予存取權，以對所有資源上的所有主體執行所有 CloudTrail 動作，但前提是請求者使用指定的 VPC 提出請求。將 *vpc-id* 取代為您的 VPC ID。

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

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "cloudtrail:*",
      "Resource": "*",
      "Principal": "*",
      "Condition": {
        "StringEquals": {
        "aws:SourceVpc": "vpc-1234567890abcdef0"
        }
      }
    }
  ]
}
```

------

### 範例：允許來自特定 VPC 端點的所有 CloudTrail 動作
<a name="create-VPC-endpoint-policy-example6"></a>

下列範例 VPC 端點政策授予存取權，以對所有資源上的所有主體執行所有 CloudTrail 動作，但前提是請求者使用指定的 VPC 端點提出請求。將 *vpc-endpoint-id* 取代為您的 VPC 端點 ID。

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

****  

```
{
     "Version":"2012-10-17",		 	 	 
     "Statement": [
       {
         "Effect": "Allow",
         "Action": "cloudtrail:*",
         "Resource": "*",
         "Condition": {
             "StringEquals": {
                "aws:SourceVpce": "vpce-1a2b3c4d"
             }
         }
       }
    ]
  }
```

------

## 共用子網路
<a name="shared-subnet-cloudtrail"></a>

與任何其他 VPC 端點類似，只有共用子網路的擁有者帳戶才能建立 CloudTrail VPC 端點。不過，參與者帳戶可以使用子網路中與參與者帳戶共用的 CloudTrail VPC 端點。如需有關 Amazon VPC 共用的詳細資訊，請參閱《Amazon VPC 使用者指南》**中的[與其他帳戶共用 VPC](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-sharing.html)。