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
#8
below code print names only for those who have Name tag

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)
# Get all snapshots
snapshots = client.describe_snapshots(OwnerIds=['self'],Filters=[{'Name': 'tag:Name', 'Values': ['*']}])
# To print only the Name of the snapshots
for snapshot in snapshots['Snapshots']:
    for tag in snapshot['Tags']:
        if tag['Key'] == 'Name':
            print (snapshot['SnapshotId'],tag['Value'])
            break
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 572 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  tuple indices must be integers or slices, not str cybertooth 16 11,835 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,247 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Response.json list indices must be integers or slices, not str [SOLVED] AlphaInc 4 6,517 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,501 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 783 Jul-30-2022, 04:06 PM
Last Post: gw1500se
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,945 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