Sử dụng thẻ bằng CLI

Nội dung:

Thêm thẻ cho tài nguyên hiện có

Sử dụng CLI create-tags với tham số –resources–tags
VD: aws ec2 create-tags –resources ami-78a54011 –tags Key=Stack,Value=production

Thêm thẻ cho tài nguyên mới

Thêm thẻ cho máy ảo mới

Sử dụng CLI run-instances để tạo máy ảo mới và dùng tham số –tag-spectifications để khai báo thông tin thẻ
VD:

aws ec2 run-instances \

--image-id ami-abc12345 \

--count 1 \

--instance-type t2.micro \

--key-name MyKeyPair \

--subnet-id subnet-6e7f829e \

--tag-specifications 'ResourceType=instance,Tags=[{Key=cost-center,Value=cc123}]' 'ResourceType=volume,Tags=[{Key=cost-center,Value=cc123}]' 
Thêm thẻ cho ổ đĩa mới

Sử dụng CLI create-volume để tạo volume mới và dùng tham số –tag-specifications để khai báo thông tin thẻ
VD:

aws ec2 create-volume \

--availability-zone us-east-1a \

--volume-type gp2 \

--size 80 \

--tag-specifications 'ResourceType=volume,Tags=[{Key=purpose,Value=production},{Key=cost-center,Value=cc123}]'

Mô tả các tài nguyên được gắn thẻ

Sử dụng CLI derscibe-instances với tham số --filters
VD: aws ec2 describe-instances --filters Name=tag-key,Values=Stack