

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

# 建立儲存庫連結
<a name="repositorylinks-create"></a>

您可以使用 AWS Command Line Interface (AWS CLI) 中的 **create-repository-link**命令，在連線與要同步的外部儲存庫之間建立連結。

在建立儲存庫連結之前，您必須先使用第三方提供者 (例如 GitHub) 建立外部儲存庫。

**建立儲存庫連結**

1. 開啟終端機 (Linux、macOS 或 Unix) 或命令提示 (Windows)。使用 AWS CLI 執行 **create-repository-link**命令。指定關聯連線的 ARN、擁有者 ID 和儲存庫名稱。

   ```
   aws codeconnections create-repository-link --connection-arn  arn:aws:codeconnections:us-east-1:account_id:connection/001f5be2-a661-46a4-b96b-4d277cac8b6e --owner-id account_id --repository-name MyRepo 
   ```

1. 此命令會傳回下列輸出。

   ```
   {
       "RepositoryLinkInfo": {
           "ConnectionArn": "arn:aws:codeconnections:us-east-1:account_id:connection/aEXAMPLE-8aad-4d5d-8878-dfcab0bc441f",
           "OwnerId": "account_id",
           "ProviderType": "GitHub",
           "RepositoryLinkArn": "arn:aws:codeconnections:us-east-1:account_id:repository-link/be8f2017-b016-4a77-87b4-608054f70e77",
           "RepositoryLinkId": "be8f2017-b016-4a77-87b4-608054f70e77",
           "RepositoryName": "MyRepo",
           "Tags": []
       }
   }
   ```