Im trying to grab a list of subnets from aws, I have a working version for VPC that I have modified:
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?
To access the subnets collection of ec2
resource,
subnets = list(ec2.subnets.filter(Filters=filters))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With