Describes a route table.
Example #1
0
        public async Task disassociateAndDeleteRouteTableAsync(RouteTable table)
        {
            bool isMain = false;
            foreach (var association in table.Associations)
            {
                if (!association.Main)
                {
                   await _ec2Client.DisassociateRouteTableAsync(new DisassociateRouteTableRequest { AssociationId = association.RouteTableAssociationId });
                }
                else
                {
                    isMain = true;
                }
            }

            foreach (var route in table.Routes)
            {
                if (route.GatewayId != "local")
                {
                    await _ec2Client.DeleteRouteAsync(new DeleteRouteRequest
                    {
                        RouteTableId = table.RouteTableId,
                        DestinationCidrBlock = route.DestinationCidrBlock
                    });
                }
            }

            if (!isMain)
            {
                await _ec2Client.DeleteRouteTableAsync(new DeleteRouteTableRequest { RouteTableId = table.RouteTableId });
            }
        }