AWS标签编辑器有两个不同的界面,分别是“控制台”界面和“CLI”界面。
import boto3
# 创建EC2客户端
ec2_client = boto3.client('ec2')
# 定义资源ID和标签
resource_id = 'your-resource-id'
tags = [
{
'Key': 'key1',
'Value': 'value1'
},
{
'Key': 'key2',
'Value': 'value2'
}
]
# 使用标签编辑器来编辑资源的标签
response = ec2_client.create_tags(
Resources=[resource_id],
Tags=tags
)
print("标签已成功创建/更新")
aws ec2 create-tags --resources your-resource-id --tags Key=key1,Value=value1 Key=key2,Value=value2
请注意,上述示例中的"your-resource-id"应替换为您要编辑标签的实际资源ID。
上一篇:AWS边缘位置与本地区的比较
下一篇:AWS标签键和值是什么?