

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

# 來源與目標端點
<a name="CHAP_Endpoints.Creating"></a>

您可以在建立複寫執行個體時建立來源與目標端點，或者，您可以在建立複寫執行個體之後建立端點。來源和目標資料存放區可位於 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體、Amazon Relational Database Service (Amazon RDS) 資料庫執行個體或現場部署資料庫中。（請注意，您的其中一個端點必須位於 AWS 服務上。 您無法使用 AWS DMS 從內部部署資料庫遷移到另一個內部部署資料庫。)

下列程序假設您已選擇 DMS AWS 主控台精靈。請注意，您也可以從 AWS DMS 主控台的導覽窗格中選取**端點**，然後選取**建立端點**來執行此步驟。使用主控台精靈時，您可以在相同的頁面中建立來源與目標端點。未使用主控台精靈時，您必須分別建立每個端點。

**使用 AWS 主控台指定來源或目標資料庫端點**

1. 在**連線來源與目標資料庫端點**頁面中，指定來源或目標資料庫的連線資訊。下表說明相關設定。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/dms/latest/userguide/CHAP_Endpoints.Creating.html)

   下表列出端點密碼中不支援的字元，以及所列資料庫引擎的秘密管理員秘密。如果您想要在端點密碼中使用逗號 (，)，請使用 中提供的 Secrets Manager 支援 AWS DMS 來驗證對 AWS DMS 執行個體的存取。如需詳細資訊，請參閱[使用秘密存取 AWS Database Migration Service 端點](security_iam_secretsmanager.md)。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/dms/latest/userguide/CHAP_Endpoints.Creating.html)

1. 視需要選擇**端點設定**和 **AWS KMS key **。您可以選擇**執行測試**以測試端點連線。下表說明相關設定。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/dms/latest/userguide/CHAP_Endpoints.Creating.html)

# 在 中使用 Amazon RDS 端點的 IAM 身分驗證 AWS DMS
<a name="CHAP_Endpoints.Creating.IAMRDS"></a>

AWS Identity and Access Management (IAM) 資料庫身分驗證透過 AWS IAM 憑證管理資料庫存取，為您的 Amazon RDS 資料庫提供增強的安全性。IAM 身分驗證不使用傳統的資料庫密碼，而是使用 AWS 登入資料產生短期身分驗證字符，有效期為 15 分鐘。這種方法可大幅提高安全性，無需將資料庫密碼儲存在應用程式程式碼中、降低憑證暴露的風險，並透過 IAM 提供集中式存取管理。它還利用現有的 AWS IAM 角色和政策來簡化存取管理，讓您能夠使用與其他 AWS 服務相同的 IAM 架構來控制資料庫存取。

AWS DMS 現在支援在 Amazon RDS 上連線至 MySQL、PostgreSQL、Aurora PostgreSQL、Aurora MySQL 或 MariaDB 端點時，針對執行 DMS 3.6.1 版或更新版本的複寫執行個體進行 IAM 身分驗證。為這些引擎建立新的端點時，您可以選擇 IAM 身分驗證並指定 IAM 角色，而不是提供資料庫登入資料。此整合不需要為遷移任務管理和存放資料庫密碼，因此可增強安全性。

## 在 中設定 Amazon RDS 端點的 IAM 身分驗證 AWS DMS
<a name="CHAP_Endpoints.Creating.IAMRDS.config"></a>

建立端點時，您可以為 Amazon RDS 資料庫設定 IAM 身分驗證。若要設定 IAM 身分驗證，請執行下列動作：

### DMS 主控台
<a name="CHAP_Endpoints.Creating.IAMRDS.console"></a>

1. 確保 Amazon RDS 和資料庫使用者已啟用 IAM 身分驗證。如需詳細資訊，請參閱《*Amazon Relational Database Service * [Database Service 使用者指南》中的啟用和停用 IAM 資料庫身分](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Enabling.html)驗證。

1. 導覽至 IAM 主控台，使用下列政策建立 IAM 角色：

   政策

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "VisualEditor0",
               "Effect": "Allow",
               "Action": [
                   "rds-db:connect"
               ],
               "Resource": "*"
           }
       ]
   }
   ```

------

   信任政策：

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "",
               "Effect": "Allow",
               "Principal": {
                   "Service": [
                       "dms.amazonaws.com"
                   ]
               },
               "Action": "sts:AssumeRole"
           }
       ]
   }
   ```

------

1. 在[https://console.aws.amazon.com/dms/v2](https://console.aws.amazon.com/dms/v2)的端點組態期間，導覽至**存取端點資料庫**區段，然後選取 **IAM 身分驗證**。

1. 在 **RDS 資料庫身分驗證的 IAM 角色**下拉式功能表中，選取具有適當許可的 IAM 角色以存取資料庫。

    如需詳細資訊，請參閱[建立來源和目標端點](https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Endpoints.Creating.html)。

### AWS CLI
<a name="CHAP_Endpoints.Creating.IAMRDS.awscli"></a>

1. 確保 Amazon RDS 和資料庫使用者已啟用 IAM 身分驗證。如需詳細資訊，請參閱《*Amazon Relational Database Service * [Database Service 使用者指南》中的啟用和停用 IAM 資料庫身分](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Enabling.html)驗證。

1. 導覽至 AWS CLI、建立 IAM 角色，並允許 DMS 擔任該角色：

   政策：

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "VisualEditor0",
               "Effect": "Allow",
               "Action": [
                   "rds-db:connect"
               ],
               "Resource": "*"
           }
       ]
   }
   ```

------

   信任政策：

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "",
               "Effect": "Allow",
               "Principal": {
                   "Service": [
                       "dms.amazonaws.com"
                   ]
               },
               "Action": "sts:AssumeRole"
           }
       ]
   }
   ```

------

1. 執行下列命令來匯入憑證並下載 PEM 檔案。如需詳細資訊，請參閱[《Amazon Relational Database Service 使用者指南》中的下載 Amazon RDS 的憑證套件](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html#UsingWithRDS.SSL.CertificatesDownload)。 *Amazon Relational Database Service * 

   ```
   aws dms import-certificate --certificate-identifier rdsglobal --certificate-pem file://~/global-bundle.pem
   ```

1. 執行下列命令來建立 IAM 端點：
   + 對於 PostgreSQL/Aurora PostgreSQL 端點 （當 `sslmode` 設定為 時`required`，不需要`--certificate-arn`旗標）：

     ```
     aws dms create-endpoint --endpoint-identifier <endpoint-name> --endpoint-type <source/target> --engine-name <postgres/aurora-postgres> --username <db username with iam auth privileges> --server-name <db server name> --port <port number> --ssl-mode <required/verify-ca/verify-full> --postgre-sql-settings "{\"ServiceAccessRoleArn\": \"role arn created from step 2 providing permissions for iam authentication\", \"AuthenticationMethod\": \"iam\", \"DatabaseName\": \"database name\"}" --certificate-arn <if sslmode is verify-ca/verify full use cert arn generated in step 3, otherwise this parameter is not required>
     ```
   + 對於 MySQL、MariaDB 或 Aurora MySQL 端點：

     ```
     aws dms create-endpoint --endpoint-identifier <endpoint-name> --endpoint-type <source/target> --engine-name <mysql/mariadb/aurora> --username <db username with iam auth privileges> --server-name <db server name> --port <port number> --ssl-mode <verify-ca/verify-full> --my-sql-settings "{\"ServiceAccessRoleArn\": \"role arn created from step 2 providing permissions for iam authentication\", \"AuthenticationMethod\": \"iam\", \"DatabaseName\": \"database name\"}" --certificate-arn <cert arn from previously imported cert in step 3>
     ```

1. 針對所需的複寫執行個體執行測試連線，以建立執行個體端點關聯，並確認一切設定正確：

   ```
   aws dms test-connection --replication-instance-arn <replication instance arn> --endpoint-arn <endpoint arn from previously created endpoint in step 4>
   ```
**注意**  
使用 IAM 身分驗證時，測試連線中提供的複寫執行個體必須位於 3.6.1 AWS DMS 版或更新版本。

## 限制
<a name="CHAP_Endpoints.Creating.IAMRDS.Limitations"></a>

AWS DMS 搭配 Amazon RDS 端點使用 IAM 身分驗證時有下列限制：
+ 目前，Amazon RDS PostgreSQL 和 Amazon Aurora PostgreSQL 執行個體不支援具有 IAM 身分驗證的 CDC 連線。如需詳細資訊，請參閱《*Amazon Relational Database Service 使用者指南》中的 *[IAM 資料庫身分驗證限制](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html#UsingWithRDS.IAMDBAuth.Limitations)。