我正在使用python进行AWS基础架构自动化。 我需要获得路由表附带的资源,其中给出的API是
ec2 = boto3.resource('ec2')
route_table_association = ec2.RouteTableAssociation('rtb-**********')
response=route_table_association.get_available_subresources()
这里的响应返回类型一直给我空列表。并且response=route_table_association.delete()
给出例外
An error occurred (InvalidAssociationID.NotFound) when calling the `DisassociateRouteTable operation: The association ID 'rtb-*********' does not exist.`
但路由tebale存在并明确附加到子网
答案 0 :(得分:0)
所需的ID为RouteTableAssociationId i.e. rtbassoc-xxxxxx ,不是路线表ID 。
RouteTableAssociationId位于describe_route_tables响应JSON'Associations'元素内。
{
'RouteTables': [
{
'RouteTableId': 'string',
'VpcId': 'string',
'Routes': [
{....}
],
'Associations': [
{
'RouteTableAssociationId': 'string',
'RouteTableId': 'string',
'SubnetId': 'string',
'Main': True|False
},
],
.....
}
答案 1 :(得分:0)
谢谢这对我有用。
response = client.describe_route_tables(
RouteTableIds=[
routetable,
],
Filters=[
{
'Name': 'route-table-id',
'Values': [
routetable
]
}
]
)