AWS CLI를 사용하여 비용 할당 태그 관리
AWS CLI를 사용하여 비용 할당 태그를 추가, 수정 또는 제거할 수 있습니다.
비용 할당 태그는 ElastiCache for Memcached 클러스터에 적용됩니다. 태그를 지정할 클러스터는 Amazon 리소스 이름(ARN)을 사용해 지정합니다.
샘플 arn: arn:aws:elasticache:us-west-2:1234567890:cluster:my-cluster
샘플 arn: arn:aws:elasticache:us-west-2:1234567890:cluster:my-cluster
AWS CLI를 사용하여 태그 나열
list-tags-for-resource 작업을 사용하여 기존 ElastiCache 리소스에서 태그를 나열하는 데 AWS CLI를 사용할 수 있습니다.
다음 코드는 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
이 작업의 출력은 다음 리소스의 모든 태그 목록과 유사합니다.
{
"TagList": [
{
"Value": "10110",
"Key": "CostCenter"
},
{
"Value": "EC2",
"Key": "Service"
}
]
}
리소스에 태그가 없으면 출력은 빈 TagList가 됩니다.
{
"TagList": []
}
자세한 내용은 ElastiCache list-tags-for-resource에 대한 AWS CLI 섹션을 참조하세요.
AWS CLI를 사용하여 태그 추가
add-tags-to-resource CLI 작업을 사용하여 기존 ElastiCache 리소스에 태그를 추가하는 데 AWS CLI를 사용할 수 있습니다. 리소스에 태그 키가 없으면 키와 값이 리소스에 추가됩니다. 리소스에 이미 키가 있는 경우 해당 키와 연결된 값이 새 값으로 업데이트됩니다.
다음 코드는 AWS CLI를 사용하여 us-west-2 리전에 있는 클러스터 my-cluster
의 에 각각 elasticache
및 us-west-2
값을 갖는 Service
및 Region
키를 추가합니다.
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
이 작업의 출력은 다음 작업 후 리소스의 모든 태그 목록과 유사합니다.
{
"TagList": [
{
"Value": "elasticache",
"Key": "Service"
},
{
"Value": "us-west-2",
"Key": "Region"
}
]
}
자세한 내용은 ElastiCache add-tags-to-resource에 대한 AWS CLI 섹션을 참조하세요.
AWS CLI을 통해 create-cache-cluster 작업을 사용하여 새 클러스터를 생성할 때 클러스터에 태그를 추가할 수도 있습니다. ElastiCache 관리 콘솔을 사용하는 경우 클러스터를 생성할 때 태그를 추가할 수 없습니다. 클러스터가 생성된 후에는 콘솔을 사용하여 클러스터에 태그를 추가할 수 있습니다.
AWS CLI를 사용하여 태그 수정
AWS CLI를 사용하여 ElastiCache for Memcached 클러스터의 태그를 수정할 수 있습니다.
태그를 수정하려면
-
add-tags-to-resource를 사용하여 새 태그 및 값을 추가하거나 기존 태그에 연결된 값을 변경합니다.
-
remove-tags-from-resource를 사용하여 리소스에서 지정된 태그를 제거합니다.
두 작업 중 하나의 출력은 지정된 클러스터의 태그와 이 태그의 값이 나열된 목록입니다.
AWS CLI를 사용하여 태그 제거
remove-tags-from-resource 작업을 사용하여 기존 ElastiCache for Memcached 클러스터에서 태그를 제거하는 데 AWS CLI를 사용할 수 있습니다.
다음 코드에서는 AWS CLI를 사용하여 us-west-2 리전에 있는 클러스터 my-cluster
의 에서 Service
및 Region
키를 갖는 태그를 제거합니다.
Linux, macOS 또는 Unix의 경우는 다음과 같습니다.
aws elasticache remove-tags-from-resource \ --resource-name arn:aws:elasticache:
us-west-2:0123456789:cluster:my-cluster
\ --tag-keysPM Service
Windows의 경우:
aws elasticache remove-tags-from-resource ^ --resource-name arn:aws:elasticache:
us-west-2:0123456789:cluster:my-cluster
^ --tag-keysPM Service
이 작업의 출력은 다음 작업 후 리소스의 모든 태그 목록과 유사합니다.
{
"TagList": []
}
자세한 내용은 ElastiCache remove-tags-from-resource에 대한 AWS CLI 섹션을 참조하세요.