Im trying to grab a list of subnets from aws, I have a working version for VPC that I have modified:
JavaScript
x
14
14
1
ec2 = boto3.resource('ec2')
2
client = boto3.client('ec2')
3
4
filters = [{'Name':'tag:Name', 'Values':['*']}]
5
subnets = list(ec2.Subnet.filter(Filters=filters))
6
7
for subnet in subnets:
8
response = client.describe_subnets(
9
VpcIds=[
10
vpc.id,
11
]
12
)
13
print(response['Subnets'])
14
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?
Advertisement
Answer
To access the subnets collection of ec2
resource,
JavaScript
1
2
1
subnets = list(ec2.subnets.filter(Filters=filters))
2