を使用したコスト配分タグの管理 AWS CLI - Amazon ElastiCache

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

を使用したコスト配分タグの管理 AWS CLI

を使用して、コスト配分タグ AWS CLI を追加、変更、または削除できます。

コスト配分タグは、ElastiCache クラスターに適用されます。タグ付けされるクラスターは、ARN (Amazon リソースネーム) を使用して指定されます。

サンプル arn: arn:aws:elasticache:us-west-2:1234567890:cluster:my-cluster

を使用したタグの一覧表示 AWS CLI

オペレーションを使用して、 を使用して既存の ElastiCache リソースのタグを AWS CLI 一覧表示できますlist-tags-for-resource。

次のコードでは AWS CLI 、 を使用して、us-west-2 リージョンの Memcached クラスターmy-clusterのタグを一覧表示します。

Linux、macOS、Unix の場合:

aws elasticache list-tags-for-resource \ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster

Windows の場合:

aws elasticache list-tags-for-resource ^ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster

次のコードは、 を使用して AWS CLI 、us-west-2 リージョンのmy-clusterクラスターmy-cluster-001内の Valkey または Redis OSS ノードのタグを一覧表示します。

Linux、macOS、Unix の場合:

aws elasticache list-tags-for-resource \ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster-001

Windows の場合:

aws elasticache list-tags-for-resource ^ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster-001

このオペレーションの出力は、リソースのすべてのタグを示した次のリストのようになります。

{ "TagList": [ { "Value": "10110", "Key": "CostCenter" }, { "Value": "EC2", "Key": "Service" } ] }

リソースにタグが見つからない場合は、空の TagList が出力されます。

{ "TagList": [] }

詳細については、「 for ElastiCache AWS CLI 」を参照してくださいlist-tags-for-resource。

を使用したタグの追加 AWS CLI

CLI オペレーションを使用して、 を使用して既存の ElastiCache add-tags-to-resource リソースにタグ AWS CLI を追加できます。タグキーがリソースに存在しない場合は、キーと値がリソースに追加されます。キーが既にリソースに存在する場合、キーに関連付けられた値は新しい値に更新されます。

次のコードでは AWS CLI 、 を使用して、us-west-2 my-clusterリージョンのクラスターmy-cluster-001内のノードにキー Service と を値 elasticacheRegionus-west-2それぞれ追加します。

Memcached

Linux、macOS、Unix の場合:

aws elasticache add-tags-to-resource \ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster \ --tags Key=Service,Value=elasticache \ Key=Region,Value=us-west-2

Windows の場合:

aws elasticache add-tags-to-resource ^ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster ^ --tags Key=Service,Value=elasticache ^ Key=Region,Value=us-west-2

Redis

Linux、macOS、Unix の場合:

aws elasticache add-tags-to-resource \ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster-001 \ --tags Key=Service,Value=elasticache \ Key=Region,Value=us-west-2

Windows の場合:

aws elasticache add-tags-to-resource ^ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster-001 ^ --tags Key=Service,Value=elasticache ^ Key=Region,Value=us-west-2

このオペレーションの出力は、次のオペレーションのリソースのすべてのタグを示した以下のリストのようになります。

{ "TagList": [ { "Value": "elasticache", "Key": "Service" }, { "Value": "us-west-2", "Key": "Region" } ] }

詳細については、「 for ElastiCache AWS CLI 」を参照してくださいadd-tags-to-resource。

オペレーション を使用して新しいクラスターを作成するときに、 を使用してクラスターにタグ AWS CLI を追加することもできますcreate-cache-cluster。ElastiCache マネジメントコンソールを使用してクラスターを作成するときは、タグを追加できません。クラスターを作成した後は、コンソールを使用してクラスターにタグを追加できます。

を使用したタグの変更 AWS CLI

を使用して AWS CLI 、ElastiCache クラスターのタグを変更できます。

タグを変更するには:

  • add-tags-to-resource を使用して、新しいタグを追加するか、既存のタグに関連付けられている値を変更します。

  • remove-tags-from-resource を使用して、リソースから指定したタグを削除します。

どちらのオペレーションでも、指定のクラスターのタグとその値を示すリストが出力されます。

を使用したタグの削除 AWS CLI

オペレーションを使用して AWS CLI 、既存の ElastiCache for Memcached クラスターからタグを削除できますremove-tags-from-resource。

Memcached の場合、次のコードは AWS CLI を使用して、my-clusterus-west-2 リージョンのクラスターmy-cluster-001内のノードRegionからキー Serviceと を持つタグを削除します。

Linux、macOS、Unix の場合:

aws elasticache remove-tags-from-resource \ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster \ --tag-keys PM Service

Windows の場合:

aws elasticache remove-tags-from-resource ^ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster ^ --tag-keys PM Service

Redis OSS の場合、次のコードは AWS CLI を使用して、my-clusterus-west-2 リージョンのクラスターmy-cluster-001内のノードRegionからキー Serviceと を持つタグを削除します。

Linux、macOS、Unix の場合:

aws elasticache remove-tags-from-resource \ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster-001 \ --tag-keys PM Service

Windows の場合:

aws elasticache remove-tags-from-resource ^ --resource-name arn:aws:elasticache:us-west-2:0123456789:cluster:my-cluster-001 ^ --tag-keys PM Service

このオペレーションの出力は、次のオペレーションのリソースのすべてのタグを示した以下のリストのようになります。

{ "TagList": [] }

詳細については、「 for ElastiCache AWS CLI 」を参照してくださいremove-tags-from-resource。