2016-06-20 2 views
0

boto3을 사용하여 subnet_id (vpc)를 기반으로 route_table_id를 찾는 방법을 알아 내려고합니다. boto3 (v1.3.1), ec2.RouteTableAssociation (id)에는 api가 있습니다. 올바른 route_table_association_id로, 아래와 같이 예외를 제공, 자원의 속성이 route_table_id에 액세스하려고 :이 실패한 이유를 나는 실마리를 찾고 있어요boto3을 사용하여 subnet_id로 route_table_id 찾기

In [19]: rta.route_table_id 
--------------------------------------------------------------------------- 
ResourceLoadException      Traceback (most recent call last) 
<ipython-input-19-a7f51e66ef03> in <module>() 
----> 1 rta.route_table_id 

/usr/local/lib/python2.7/site-packages/boto3/resources/factory.pyc in property_loader(self) 
    341     else: 
    342      raise ResourceLoadException(
--> 343       '{0} has no load method'.format(self.__class__.__name__)) 
    344 
    345    return self.meta.data.get(name) 

ResourceLoadException: ec2.RouteTableAssociation has no load method 

.

response = client.describe_route_tables(
    Filters=[ 
     { 
      'Name': 'association.subnet-id', 
      'Values': [ 
       source_subnet_id 
      ] 
     } 
    ] 
) 


print(response['RouteTables'][0]['Associations'][0]['RouteTableId']) 
+0

나는 코드가 어떻게 보이는지 궁금합니다. – mootmoot

답변

2

알아낼이 방법을 수행 할 수 있습니다.

필요한 모든 정보는 [ 'RouteTables'] 응답 JSON을 받고있다 [*] [ "협회"]

관련 문제