Просто укажите список, например:
import boto3
client = boto3.client('ec2')
# Get t2.micro instances
response = client.describe_instances(
Filters=[{'Name': 'instance-type','Values':['t2.micro']}]
)
instances = [i['InstanceId'] for i in r['Instances'] for r in response['Reservations']]
# Stop the instances
client.stop_instances(InstanceIds=instances)
waiter=client.get_waiter('instance_stopped')
waiter.wait(InstanceIds=instances)
# Change the instance type
for i in instances:
client.modify_instance_attribute(InstanceId=i, Attribute='instanceType', Value='m3.xlarge')
# Start the instance
client.start_instances(InstanceIds=instances)
Я не проверял код, поэтому сначала проверьте его!