

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 创建存储库链接
<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": []
       }
   }
   ```