

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# CLI または API を使用してタグを管理する
<a name="tag-resources-api-sdk"></a>

リソースのタグの追加、更新、リスト表示、および削除には、次の AWS CLI コマンドまたは AWS Batch API オペレーションを使用します。


**AWS Batch リソースのタグのサポート**  

| タスク | API アクション | AWS CLI | AWS Tools for Windows PowerShell | 
| --- | --- | --- | --- | 
| 1 つ以上のタグを追加、または上書きします。 | [TagResource](https://docs.aws.amazon.com/batch/latest/APIReference/API_TagResource.html) | [tag-resource](https://docs.aws.amazon.com/cli/latest/reference/batch/tag-resource.html) | [追加-BATResourceTag](https://docs.aws.amazon.com/powershell/latest/reference/items/Add-BATResourceTag.html) | 
| 1 つ以上のタグを削除します。 | [UntagResource](https://docs.aws.amazon.com/batch/latest/APIReference/API_UntagResource.html) | [untag-resource](https://docs.aws.amazon.com/cli/latest/reference/batch/untag-resource.html) | [削除-BATResourceTag](https://docs.aws.amazon.com/powershell/latest/reference/items/Remove-BATResourceTag.html) | 
| リソースのタグの一覧表示 | [ListTagsForResource](https://docs.aws.amazon.com/batch/latest/APIReference/API_ListTagsForResource.html) | [list-tags-for-resource](https://docs.aws.amazon.com/cli/latest/reference/batch/list-tags-for-resource.html) | [Get-BATResourceTag](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-BATResourceTag.html) | 

以下の例では、AWS CLI を使用して、リソースに対してタグ付けまたはタグ削除する方法を示しています。

**例 1: 既存のリソースにタグ付けする**  
次のコマンドでは、既存のリソースにタグ付けします。

```
aws batch tag-resource --resource-arn {{resource_ARN}} --tags {{team}}={{devs}}
```

**例 2: 既存のリソースからタグを削除する**  
次のコマンドでは、既存のリソースからタグを削除します。

```
aws batch untag-resource --resource-arn {{resource_ARN}} --tag-keys {{tag_key}}
```

**例 3: リソースのタグのリスト取得**  
次のコマンドは、既存のリソースに関連付けられているタグのリストを取得します。

```
aws batch list-tags-for-resource --resource-arn {{resource_ARN}}
```

一部のリソース作成アクションでは、リソースの作成時にタグを指定できます。以下のアクションでは、作成時のタグ付けがサポートされます。


| タスク | API アクション | AWS CLI | AWS Tools for Windows PowerShell | 
| --- | --- | --- | --- | 
| コンピューティング環境の作成 | [CreateComputeEnvironment](https://docs.aws.amazon.com/batch/latest/APIReference/API_CreateComputeEnvironment.html) | [create-compute-environment](https://docs.aws.amazon.com/cli/latest/reference/batch/create-compute-environment.html) | [New-BATComputeEnvironment](https://docs.aws.amazon.com/powershell/latest/reference/items/New-BATComputeEnvironment.html) | 
| ジョブキューの作成 | [CreateJobQueue](https://docs.aws.amazon.com/batch/latest/APIReference/API_CreateJobQueue.html) | [create-job-queue](https://docs.aws.amazon.com/cli/latest/reference/batch/create-job-queue.html) | [New-BATJobQueue](https://docs.aws.amazon.com/powershell/latest/reference/items/New-BATJobQueue.html) | 
| スケジューリングポリシーの作成 | [CreateSchedulingPolicy](https://docs.aws.amazon.com/batch/latest/APIReference/API_CreateSchedulingPolicy.html) | [create-scheduling-policy](https://docs.aws.amazon.com/cli/latest/reference/batch/create-scheduling-policy.html) | [New-BATSchedulingPolicy](https://docs.aws.amazon.com/powershell/latest/reference/items/New-BATSchedulingPolicy.html) | 
| ジョブ定義を登録する | [RegisterJobDefinition](https://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html) | [register-job-definition](https://docs.aws.amazon.com/cli/latest/reference/batch/register-job-definition.html) | [Register-BATJobDefinition](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-BATJobDefinition.html) | 
| ジョブを送信する | [SubmitJob](https://docs.aws.amazon.com/batch/latest/APIReference/API_SubmitJob.html) | [submit-job](https://docs.aws.amazon.com/cli/latest/reference/batch/submit-job.html) | [Submit-BATJob](https://docs.aws.amazon.com/powershell/latest/reference/items/Submit-BATJob.html) | 
| 消費型リソースの作成 | [CreateConsumableResource](https://docs.aws.amazon.com/batch/latest/APIReference/API_CreateConsumableResource.html) | [create-consumable-resource](https://docs.aws.amazon.com/cli/latest/reference/batch/create-consumable-resource.html) | [Create-BATConsumableResource](https://docs.aws.amazon.com/powershell/latest/reference/items/Create-BATConsumableResource.html) | 