예제 #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 });
            }
        }
예제 #2
0
        public async Task DeleteRouteForRouteTable(string destinationCidrBlock, string routeTableId)
        {
            try
            {
                var request = new DeleteRouteRequest()
                {
                    DestinationCidrBlock = destinationCidrBlock,
                    RouteTableId         = routeTableId
                };

                await client.DeleteRouteAsync(request);
            }
            catch (Exception ex)
            {
                //Check if destinationCidrBlock doesn't exist, should skip
                throw ex;
            }
        }