

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

# 為 UltraServer 容量區塊建立一個資源群組
<a name="cb-group"></a>

您可以使用 AWS Resource Groups 建立 UltraServer 容量區塊的邏輯集合。在您建立資源群組之後，可在您的帳戶中新增您擁有的 UltraServer 容量區塊。在您新增 UltraServer 容量區塊之後，可將執行個體啟動目標鎖定為資源群組，而非個別容量區塊。若執行個體鎖定一個資源群組，將會與群組中具有相符屬性及可用容量的任何 UltraServer 容量區塊進行比對。若資源群組沒有具有相符屬性及可用容量的 UltraServer 容量區塊，執行個體啟動會失敗。

如果在執行執行個體時從資源群組移除 UltraServer 容量區塊，這些執行個體會繼續在容量區塊中執行。如果群組中有一個 UltraServer 容量區塊在執行個體執行時結束，則會終止該等執行個體。

您不能新增執行個體容量區塊至資源群組。

為 UltraServer 容量區塊建立資源群組，可使用以下方法之一。

------
#### [ AWS CLI ]

**為 UltraServer 容量區塊建立資源群組**  
請使用 [create-group](https://docs.aws.amazon.com/cli/latest/reference/resource-groups/create-group.html) AWS CLI 命令，並針對 `--configuration`，指定以下各項：

```
{
  "Configuration": [
    {
      "Type": "AWS::EC2::CapacityReservationPool",
      "Parameters": [
        {
          "Name": "instance-type",
          "Values": [
            "instance_type"
          ]
        },
        {
          "Name": "reservation-type",
          "Values": [
            "capacity-block"
          ]
        }
      ]
    },
    {
      "Type": "AWS::ResourceGroups::Generic",
      "Parameters": [
        {
          "Name": "allowed-resource-types",
          "Values": [
            "AWS::EC2::CapacityReservation"
          ]
        }
      ]
    }
  ]
}
```

------
#### [ PowerShell ]

**為 UltraServer 容量區塊建立資源群組**  
使用 [New-RGGroup](https://docs.aws.amazon.com/powershell/latest/reference/items/New-RGGroup.html) cmdlet。針對 `-Configuration`，指定以下各項：

```
{
  "Configuration": [
    {
      "Type": "AWS::EC2::CapacityReservationPool",
      "Parameters": [
        {
          "Name": "instance-type",
          "Values": [
            "instance_type"
          ]
        },
        {
          "Name": "reservation-type",
          "Values": [
            "capacity-block"
          ]
        }
      ]
    },
    {
      "Type": "AWS::ResourceGroups::Generic",
      "Parameters": [
        {
          "Name": "allowed-resource-types",
          "Values": [
            "AWS::EC2::CapacityReservation"
          ]
        }
      ]
    }
  ]
}
```

------

在您為 UltraServer 容量區塊建立資源群組之後，可使用以下方法之一在該群組中新增現有的 UltraServer 容量區塊。

------
#### [ AWS CLI ]

**新增 UltraServer 容量區塊至資源群組**  
請使用 [group-resources](https://docs.aws.amazon.com/cli/latest/reference/resource-groups/group-resources.html) 命令。對於 `--group`，請為您建立的資源群組指定名稱。對於 `--resource-arns`，請為要新增的 UltraServer 容量區塊指定 ARN。

```
aws resource-groups group-resources \
--group MyCRGroup \
--resource-arns CapacityReservationArn
```

------
#### [ PowerShell ]

**新增 UltraServer 容量區塊至資源群組**  
使用 [Add-RGResource](https://docs.aws.amazon.com/powershell/latest/reference/items/Add-RGResource.html) cmdlet。對於 `-Group`，請為您建立的資源群組指定名稱。對於 `-ResourceArn `，請為要新增的 UltraServer 容量區塊指定 ARN。

下列範例會新增兩個容量保留到指定群組。

```
Add-RGResource `
-Group MyCRGroup `
-ResourceArn CapacityReservationArn
```

------