2017-01-17 101 views
3

我試着去抓住從AWS子網列表,我有VPC一個工作版本,我已經修改:AWS boto3搶子網信息

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']) 

我不斷收到:

subnets = list(ec2.Subnet.filters(Filters=filters)) AttributeError: 'function' object has no attribute 'filters'

從一切即時消息和其他例子,這應該工作

任何想法?

+0

感謝隊友的工作魅力。 – ben

回答

0

要訪問ec2資源的子網集合,

subnets = list(ec2.subnets.filter(Filters=filters))