mirror of https://github.com/hashicorp/terraform
provider/azurerm: support import for load balancer and sub resources (#11610)
implemented ResourceImporter for sub resources which extracts the lb id deprecated location on each sub resource as it was unusedpull/11613/head
parent
db9e67190e
commit
bbde0537d1
@ -0,0 +1,35 @@
|
||||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAzureRMLoadBalancerBackEndAddressPool_importBasic(t *testing.T) {
|
||||
resourceName := "azurerm_lb_backend_address_pool.test"
|
||||
|
||||
ri := acctest.RandInt()
|
||||
addressPoolName := fmt.Sprintf("%d-address-pool", ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureRMLoadBalancerBackEndAddressPool_basic(ri, addressPoolName),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
// location is deprecated and was never actually used
|
||||
ImportStateVerifyIgnore: []string{"location"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAzureRMLoadBalancerNatPool_importBasic(t *testing.T) {
|
||||
resourceName := "azurerm_lb_nat_pool.test"
|
||||
|
||||
ri := acctest.RandInt()
|
||||
natPoolName := fmt.Sprintf("NatPool-%d", ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureRMLoadBalancerNatPool_basic(ri, natPoolName),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
// location is deprecated and was never actually used
|
||||
ImportStateVerifyIgnore: []string{"location"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAzureRMLoadBalancerNatRule_importBasic(t *testing.T) {
|
||||
resourceName := "azurerm_lb_nat_rule.test"
|
||||
|
||||
ri := acctest.RandInt()
|
||||
natRuleName := fmt.Sprintf("NatRule-%d", ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureRMLoadBalancerNatRule_basic(ri, natRuleName),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
// location is deprecated and was never actually used
|
||||
ImportStateVerifyIgnore: []string{"location"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAzureRMLoadBalancerProbe_importBasic(t *testing.T) {
|
||||
resourceName := "azurerm_lb_probe.test"
|
||||
|
||||
ri := acctest.RandInt()
|
||||
probeName := fmt.Sprintf("probe-%d", ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureRMLoadBalancerProbe_basic(ri, probeName),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
// location is deprecated and was never actually used
|
||||
ImportStateVerifyIgnore: []string{"location"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAzureRMLoadBalancerRule_importBasic(t *testing.T) {
|
||||
resourceName := "azurerm_lb_rule.test"
|
||||
|
||||
ri := acctest.RandInt()
|
||||
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureRMLoadBalancerRule_basic(ri, lbRuleName),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
// location is deprecated and was never actually used
|
||||
ImportStateVerifyIgnore: []string{"location"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package azurerm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAzureRMLoadBalancer_importBasic(t *testing.T) {
|
||||
resourceName := "azurerm_lb.test"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMLoadBalancerDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureRMLoadBalancer_basic(acctest.RandInt()),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
Loading…
Reference in new issue