Question:
Im trying to grab a list of subnets from aws, I have a working version for VPC that I have modified:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
ec2 = boto3.resource('ec2') client = boto3.client('ec2') filters = [{'Name':'tag:Name', 'Values':['*']}] subnets = list(ec2.Subnet.filter(Filters=filters)) for subnet in subnets: response = client.describe_subnets( VpcIds=[ vpc.id, ] ) print(response['Subnets']) |
I keep getting:
subnets = list(ec2.Subnet.filters(Filters=filters)) AttributeError:
‘function’ object has no attribute ‘filters’
From everything im reading and other examples this should work
Any ideas?
Answer:
To access the subnets collection of ec2
resource,
1 2 |
subnets = list(ec2.subnets.filter(Filters=filters)) |