

# 创建 IVS 聊天室的 CLI 说明
<a name="create-room-cli"></a>

本文档将引导您完成使用 AWS CLI 创建 Amazon IVS 聊天室所涉及的步骤。

## 创建聊天室
<a name="create-room-cli-chat-room"></a>

使用 Amazon CLI 创建聊天室是一个高级选项，需要先在计算机上下载并配置 CLI。有关详细信息，请参阅 [Amazon 命令行界面用户指南](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)。

1. 运行聊天 `create-room` 命令并传入一个可选名称：

   ```
   aws ivschat create-room --name test-room
   ```

1. 这将返回一个新的聊天室：

   ```
   {  
      "arn": "arn:aws:ivschat:us-west-2:123456789012:room/g1H2I3j4k5L6",
      "id": "string",
      "createTime": "2021-06-07T14:26:05-07:00",
      "maximumMessageLength": 200, 
      "maximumMessageRatePerSecond": 10,
      "name": "test-room",
      "tags": {},
      "updateTime": "2021-06-07T14:26:05-07:00"
   }
   ```

1. 请注意 `arn` 字段。您需要它来创建客户端令牌并连接到聊天室。

## 设置日志记录配置（可选）
<a name="create-room-cli-logging"></a>

与创建聊天室一样，使用 Amazon CLI 设置日志记录配置是一个高级选项，需要先在计算机上下载并配置 CLI。有关详细信息，请参阅 [Amazon 命令行界面用户指南](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)。

1. 运行聊天 `create-logging-configuration` 命令并传入可选名称和按名称指向 Amazon S3 存储桶的目标配置。在创建日志记录配置之前，此 Amazon S3 存储桶必须存在。（有关创建 Amazon S3 存储桶的详细信息，请参阅 [Amazon S3 文档](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)。）

   ```
   aws ivschat create-logging-configuration \
      --destination-configuration s3={bucketName=demo-logging-bucket} \
      --name "test-logging-config"
   ```

1. 这将返回一个新的日志记录配置：

   ```
   {
      "Arn": "arn:aws:ivschat:us-west-2:123456789012:logging-configuration/ABcdef34ghIJ",
      "createTime": "2022-09-14T17:48:00.653000+00:00",
      "destinationConfiguration": { 
         "s3": {"bucketName": "demo-logging-bucket"}
      },
      "id": "ABcdef34ghIJ",
      "name": "test-logging-config",
      "state": "ACTIVE",
      "tags": {},
      "updateTime": "2022-09-14T17:48:01.104000+00:00"
   }
   ```

1. 请注意 `arn` 字段。您需要此字段来将日志记录配置附加到聊天室。

   1. 如果您要创建新的聊天室，请运行 `create-room` 命令并传递日志记录配置 `arn`：

      ```
      aws ivschat create-room --name test-room \ 
      --logging-configuration-identifiers \
      "arn:aws:ivschat:us-west-2:123456789012:logging-configuration/ABcdef34ghIJ"
      ```

   1. 如果您要更新现有的聊天室，请运行 `update-room` 命令并传递日志记录配置 `arn`：

      ```
      aws ivschat update-room --identifier \
      "arn:aws:ivschat:us-west-2:12345689012:room/g1H2I3j4k5L6" \
      --logging-configuration-identifiers \
      "arn:aws:ivschat:us-west-2:123456789012:logging-configuration/ABcdef34ghIJ"
      ```