-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 unused
- Loading branch information
1 parent
db9e671
commit bbde053
Showing
19 changed files
with
423 additions
and
26 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
builtin/providers/azurerm/import_arm_loadbalancer_backend_address_pool_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}, | ||
}, | ||
}, | ||
}) | ||
} |
35 changes: 35 additions & 0 deletions
35
builtin/providers/azurerm/import_arm_loadbalancer_nat_pool_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}, | ||
}, | ||
}, | ||
}) | ||
} |
35 changes: 35 additions & 0 deletions
35
builtin/providers/azurerm/import_arm_loadbalancer_nat_rule_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}, | ||
}, | ||
}, | ||
}) | ||
} |
35 changes: 35 additions & 0 deletions
35
builtin/providers/azurerm/import_arm_loadbalancer_probe_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}, | ||
}, | ||
}, | ||
}) | ||
} |
35 changes: 35 additions & 0 deletions
35
builtin/providers/azurerm/import_arm_loadbalancer_rule_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.