Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何通过添加标记重命名已创建的快照_Python_Amazon Web Services_Snapshot - Fatal编程技术网

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',请按照文档进行操作:非常感谢您!!这就是我要找的。成功运作