Python Forum
boto3 - Error - TypeError: string indices must be integers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
boto3 - Error - TypeError: string indices must be integers
#1
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




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
    )
Reply


Messages In This Thread
boto3 - Error - TypeError: string indices must be integers - by kpatil - Jun-09-2023, 05:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 569 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  tuple indices must be integers or slices, not str cybertooth 16 11,812 Nov-02-2023, 01:20 PM
Last Post: brewer32
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,246 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Response.json list indices must be integers or slices, not str [SOLVED] AlphaInc 4 6,514 Mar-24-2023, 08:34 AM
Last Post: fullytotal
  "TypeError: string indices must be integers, not 'str'" while not using any indices bul1t 2 2,082 Feb-11-2023, 07:03 PM
Last Post: deanhystad
  Error "list indices must be integers or slices, not str" dee 2 1,500 Dec-30-2022, 05:38 PM
Last Post: dee
  Error TypeError: output_type_handler() takes 2 positional arguments but 6 were given paulo79 1 1,990 Oct-17-2022, 06:29 PM
Last Post: paulo79
  TypeError: string indices must be integers JonWayn 12 3,526 Aug-31-2022, 03:29 PM
Last Post: deanhystad
  boto3 Help Needed gw1500se 0 780 Jul-30-2022, 04:06 PM
Last Post: gw1500se
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,942 Jul-01-2022, 01:23 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020