

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

# 创建同步配置
<a name="syncconfigurations-create"></a>

您可以使用 AWS Command Line Interface (AWS CLI) 中的**create-repository-link**命令在连接和要同步到的外部存储库之间创建链接。

在创建同步配置之前，您必须已经在连接和第三方存储库之间创建了存储库链接。

**创建同步配置**

1. 打开终端（Linux、macOS 或 Unix）或命令提示符（Windows）。 AWS CLI 使用运行**create-repository-link**命令。指定关联连接的 ARN、所有者 ID 和存储库名称。以下命令将创建一个同步配置，其同步类型适用于 CloudFormation中的资源。它还指定了存储库分支和存储库中的配置文件。在此示例中，资源是一个名为 **`mystack`** 的堆栈。

   ```
   aws codeconnections create-sync-configuration --branch main --config-file filename --repository-link-id be8f2017-b016-4a77-87b4-608054f70e77 --resource-name mystack --role-arn arn:aws:iam::{{account_id}}:role/myrole --sync-type CFN_STACK_SYNC
   ```

1. 此命令将返回以下输出。

   ```
   {
       "SyncConfiguration": {
           "Branch": "main",
           "ConfigFile": "filename",
           "OwnerId": "{{account_id}}",
           "ProviderType": "GitHub",
           "RepositoryLinkId": "be8f2017-b016-4a77-87b4-608054f70e77",
           "RepositoryName": "MyRepo",
           "ResourceName": "mystack",
           "RoleArn": "arn:aws:iam::{{account_id}}:role/myrole",
           "SyncType": "CFN_STACK_SYNC"
       }
   ```