Python 如何通过添加标记重命名已创建的快照
我想创建一个快照,然后向其中添加标记。这是我的代码:Python 如何通过添加标记重命名已创建的快照,python,amazon-web-services,snapshot,Python,Amazon Web Services,Snapshot,我想创建一个快照,然后向其中添加标记。这是我的代码: snapshot=ec2client.create_snapshot(VolumeId=volume_id,Description=description) print snapshot['Tags']['Key'] 我知道snapshot是一个dictionnary,将使用以下语法: { 'SnapshotId': 'string', 'VolumeId': 'string', 'State': 'pending'
snapshot=ec2client.create_snapshot(VolumeId=volume_id,Description=description)
print snapshot['Tags']['Key']
我知道snapshot
是一个dictionnary
,将使用以下语法:
{
'SnapshotId': 'string',
'VolumeId': 'string',
'State': 'pending'|'completed'|'error',
'StateMessage': 'string',
'StartTime': datetime(2015, 1, 1),
'Progress': 'string',
'OwnerId': 'string',
'Description': 'string',
'VolumeSize': 123,
'OwnerAlias': 'string',
'Tags': [
{
'Key': 'string',
'Value': 'string'
},
],
'Encrypted': True|False,
'KmsKeyId': 'string',
'DataEncryptionKeyId': 'string'
}
当我这样做的时候:
snapshot.add_tags({'foo': 'bar'})
我得到一个错误,说AttributeError:'dict'对象没有属性'add\u tags'
我想知道如何访问标记的键和值并更改它们?
要使用哪个函数?要添加或覆盖标记,必须使用createTagsAPI/函数 我们不允许在创建快照时添加标记。请使用单独的API/函数将标记添加到快照中
希望这能有所帮助,谢谢我收到了这个错误:`AttributeError:'dict'对象没有属性'createTags',请按照文档进行操作:非常感谢您!!这就是我要找的。成功运作