Hello,
Can someone help me how to fix the error i am getting here . Thanks
error is
Traceback (most recent call last):
File "/root/temp0/server", line 10, in <module>
snapshot_name = snapshot['Tags'][0]['Value']
TypeError: string indices must be integers
Can someone help me how to fix the error i am getting here . Thanks
error is
Traceback (most recent call last):
File "/root/temp0/server", line 10, in <module>
snapshot_name = snapshot['Tags'][0]['Value']
TypeError: string indices must be integers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import boto3 AWS_REGION = "us-west-2" AWS_PROFILE = "kiran" session = boto3.session.Session(profile_name = AWS_PROFILE) client = session.client( 'ec2' ,region_name = AWS_REGION) snapshots = client.describe_snapshots(SnapshotIds = [ 'snap-xxxxxx' ]) # Iterate over the snapshots for snapshot in snapshots: # Get the snapshot name snapshot_name = snapshot[ 'Tags' ][ 0 ][ 'Value' ] # Append the snapshot name to the description description = snapshot[ 'Description' ] + ' - ' + snapshot_name # Update the description client.modify_snapshot_attribute( SnapshotId = snapshot[ 'SnapshotId' ], Attribute = 'description' , OperationType = 'replace' , Description = description ) |