diff --git a/qingcloud/resource_qingcloud_vpc_help.go b/qingcloud/resource_qingcloud_vpc_help.go index 07ca90d30..90c887677 100644 --- a/qingcloud/resource_qingcloud_vpc_help.go +++ b/qingcloud/resource_qingcloud_vpc_help.go @@ -90,3 +90,10 @@ func waitRouterLease(d *schema.ResourceData, meta interface{}) error { WaitForLease(output.RouterSet[0].StatusTime) return nil } + +func isRouterDeleted(routerSet []*qc.Router) bool { + if len(routerSet) == 0 || qc.StringValue(routerSet[0].Status) == "deleted" || qc.StringValue(routerSet[0].Status) == "ceased" { + return true + } + return false +} diff --git a/qingcloud/resource_qingcloud_vpc_test.go b/qingcloud/resource_qingcloud_vpc_test.go index 362ff032d..935b317fd 100644 --- a/qingcloud/resource_qingcloud_vpc_test.go +++ b/qingcloud/resource_qingcloud_vpc_test.go @@ -244,7 +244,7 @@ func testAccCheckVpcDestroyWithProvider(s *terraform.State, provider *schema.Pro input.Routers = []*string{qc.String(rs.Primary.ID)} output, err := client.router.DescribeRouters(input) if err == nil { - if len(output.RouterSet) != 0 && qc.StringValue(output.RouterSet[0].Status) != "deleted" { + if isRouterDeleted(output.RouterSet) { return fmt.Errorf("Found Router: %s", rs.Primary.ID) } }