

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

# 使用 AWS CLI
<a name="single-region-aws-cli"></a>

AWS CLI 提供命令列界面，用於管理 Aurora DSQL 叢集。下列範例說明常見的叢集管理作業。

## 建立叢集
<a name="create-cluster"></a>

使用 **create-cluster** 命令建立叢集。

**注意**  
建立叢集為非同步作業。呼叫 **GetCluster** API，直到狀態變更為 `ACTIVE` 為止。在叢集變成作用中狀態之後，您可以連線到叢集。

**Example 命令**  

```
aws dsql create-cluster --region us-east-1
```

**注意**  
若要在建立期間停用刪除保護，請包含 `--no-deletion-protection-enabled` 標記。

**Example 回應**  

```
{
    "identifier": "abc0def1baz2quux3quuux4",
    "arn": "arn:aws:dsql:us-east-1:111122223333:cluster/abc0def1baz2quux3quuux4",
    "status": "CREATING",
    "creationTime": "2024-05-25T16:56:49.784000-07:00",
    "deletionProtectionEnabled": true,
    "tag": {},
    "encryptionDetails": {
        "encryptionType": "AWS_OWNED_KMS_KEY",
        "encryptionStatus": "ENABLED"
    }
}
```

## 描述叢集
<a name="get-cluster"></a>

使用 **get-cluster** 命令取得叢集的相關資訊。

**Example 命令**  

```
aws dsql get-cluster \
  --region us-east-1 \
  --identifier your_cluster_id
```

**Example 回應**  

```
{
    "identifier": "abc0def1baz2quux3quuux4",
    "arn": "arn:aws:dsql:us-east-1:111122223333:cluster/abc0def1baz2quux3quuux4",
    "status": "ACTIVE",
    "creationTime": "2024-11-27T00:32:14.434000-08:00",
    "deletionProtectionEnabled": false,
    "encryptionDetails": {
        "encryptionType": "CUSTOMER_MANAGED_KMS_KEY",
        "kmsKeyArn": "arn:aws:kms:us-east-1:111122223333:key/123a456b-c789-01de-2f34-g5hi6j7k8lm9",
        "encryptionStatus": "ENABLED"
    }
}
```

## 更新叢集
<a name="update-cluster"></a>

使用 **update-cluster** 命令更新現有的叢集。

**注意**  
更新為非同步作業。呼叫 **GetCluster** API，直到狀態變更為 `ACTIVE` 為止，以查看您的變更。

**Example 命令**  

```
aws dsql update-cluster \
  --region us-east-1 \
  --no-deletion-protection-enabled \
  --identifier your_cluster_id
```

**Example 回應**  

```
{
    "identifier": "abc0def1baz2quux3quuux4",
    "arn": "arn:aws:dsql:us-east-1:111122223333:cluster/abc0def1baz2quux3quuux4",
    "status": "UPDATING",
    "creationTime": "2024-05-24T09:15:32.708000-07:00"
}
```

## 刪除叢集
<a name="delete-cluster"></a>

使用 **delete-cluster** 命令刪除現有的叢集。

**注意**  
您只能刪除已停用刪除保護的叢集。當您建立叢集時，預設會啟用刪除保護。

**Example 命令**  

```
aws dsql delete-cluster \
  --region us-east-1 \
  --identifier your_cluster_id
```

**Example 回應**  

```
{
    "identifier": "abc0def1baz2quux3quuux4",
    "arn": "arn:aws:dsql:us-east-1:111122223333:cluster/abc0def1baz2quux3quuux4",
    "status": "DELETING",
    "creationTime": "2024-05-24T09:16:43.778000-07:00"
}
```

## 列出叢集
<a name="list-clusters"></a>

使用 **list-clusters** 命令列出您的叢集。

**Example 命令**  

```
aws dsql list-clusters --region us-east-1
```

**Example 回應**  

```
{
    "clusters": [
        {
            "identifier": "abc0def1baz2quux3quux4quuux",
            "arn": "arn:aws:dsql:us-east-1:111122223333:cluster/abc0def1baz2quux3quux4quuux"
        },
        {
            "identifier": "abc0def1baz2quux3quux5quuuux",
            "arn": "arn:aws:dsql:us-east-1:111122223333:cluster/abc0def1baz2quux3quux5quuuux"
        }
    ]
}
```