Merge branch 'GH-9311' of https://github.com/carinadigital/terraform into carinadigital-GH-9311
This commit is contained in:
commit
760587092a
|
@ -100,7 +100,18 @@ func resourceArmLoadBalancerBackendAddressPoolCreate(d *schema.ResourceData, met
|
|||
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
|
||||
}
|
||||
|
||||
d.SetId(*read.ID)
|
||||
var pool_id string
|
||||
for _, BackendAddressPool := range *(*read.Properties).BackendAddressPools {
|
||||
if *BackendAddressPool.Name == d.Get("name").(string) {
|
||||
pool_id = *BackendAddressPool.ID
|
||||
}
|
||||
}
|
||||
|
||||
if pool_id != "" {
|
||||
d.SetId(pool_id)
|
||||
} else {
|
||||
return fmt.Errorf("Error can not find created loadbalacner backend address pool id %s", pool_id)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
|
||||
stateConf := &resource.StateChangeConf{
|
||||
|
@ -117,7 +128,7 @@ func resourceArmLoadBalancerBackendAddressPoolCreate(d *schema.ResourceData, met
|
|||
}
|
||||
|
||||
func resourceArmLoadBalancerBackendAddressPoolRead(d *schema.ResourceData, meta interface{}) error {
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Id(), meta)
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Get("loadbalancer_id").(string), meta)
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package azurerm
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/network"
|
||||
|
@ -15,6 +16,11 @@ func TestAccAzureRMLoadBalancerBackEndAddressPool_basic(t *testing.T) {
|
|||
ri := acctest.RandInt()
|
||||
addressPoolName := fmt.Sprintf("%d-address-pool", ri)
|
||||
|
||||
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
|
||||
backendAddressPool_id := fmt.Sprintf(
|
||||
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/backendAddressPools/%s",
|
||||
subscriptionID, ri, ri, addressPoolName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -25,6 +31,8 @@ func TestAccAzureRMLoadBalancerBackEndAddressPool_basic(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
|
||||
testCheckAzureRMLoadBalancerBackEndAddressPoolExists(addressPoolName, &lb),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_lb_backend_address_pool.test", "id", backendAddressPool_id),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -122,7 +122,18 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface
|
|||
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
|
||||
}
|
||||
|
||||
d.SetId(*read.ID)
|
||||
var natPool_id string
|
||||
for _, InboundNatPool := range *(*read.Properties).InboundNatPools {
|
||||
if *InboundNatPool.Name == d.Get("name").(string) {
|
||||
natPool_id = *InboundNatPool.ID
|
||||
}
|
||||
}
|
||||
|
||||
if natPool_id != "" {
|
||||
d.SetId(natPool_id)
|
||||
} else {
|
||||
return fmt.Errorf("Error can not find created loadbalancer nat pool id %s", natPool_id)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
|
||||
stateConf := &resource.StateChangeConf{
|
||||
|
@ -139,7 +150,7 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
func resourceArmLoadBalancerNatPoolRead(d *schema.ResourceData, meta interface{}) error {
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Id(), meta)
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Get("loadbalancer_id").(string), meta)
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package azurerm
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/network"
|
||||
|
@ -15,6 +16,11 @@ func TestAccAzureRMLoadBalancerNatPool_basic(t *testing.T) {
|
|||
ri := acctest.RandInt()
|
||||
natPoolName := fmt.Sprintf("NatPool-%d", ri)
|
||||
|
||||
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
|
||||
natPool_id := fmt.Sprintf(
|
||||
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/inboundNatPools/%s",
|
||||
subscriptionID, ri, ri, natPoolName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -25,6 +31,8 @@ func TestAccAzureRMLoadBalancerNatPool_basic(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
|
||||
testCheckAzureRMLoadBalancerNatPoolExists(natPoolName, &lb),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_lb_nat_pool.test", "id", natPool_id),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -122,7 +122,18 @@ func resourceArmLoadBalancerNatRuleCreate(d *schema.ResourceData, meta interface
|
|||
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
|
||||
}
|
||||
|
||||
d.SetId(*read.ID)
|
||||
var natRule_id string
|
||||
for _, InboundNatRule := range *(*read.Properties).InboundNatRules {
|
||||
if *InboundNatRule.Name == d.Get("name").(string) {
|
||||
natRule_id = *InboundNatRule.ID
|
||||
}
|
||||
}
|
||||
|
||||
if natRule_id != "" {
|
||||
d.SetId(natRule_id)
|
||||
} else {
|
||||
return fmt.Errorf("Error can not find created loadbalancer nat rule id %s", natRule_id)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
|
||||
stateConf := &resource.StateChangeConf{
|
||||
|
@ -139,7 +150,7 @@ func resourceArmLoadBalancerNatRuleCreate(d *schema.ResourceData, meta interface
|
|||
}
|
||||
|
||||
func resourceArmLoadBalancerNatRuleRead(d *schema.ResourceData, meta interface{}) error {
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Id(), meta)
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Get("loadbalancer_id").(string), meta)
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package azurerm
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/network"
|
||||
|
@ -15,6 +16,11 @@ func TestAccAzureRMLoadBalancerNatRule_basic(t *testing.T) {
|
|||
ri := acctest.RandInt()
|
||||
natRuleName := fmt.Sprintf("NatRule-%d", ri)
|
||||
|
||||
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
|
||||
natRule_id := fmt.Sprintf(
|
||||
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/inboundNatRules/%s",
|
||||
subscriptionID, ri, ri, natRuleName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -25,6 +31,8 @@ func TestAccAzureRMLoadBalancerNatRule_basic(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
|
||||
testCheckAzureRMLoadBalancerNatRuleExists(natRuleName, &lb),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_lb_nat_rule.test", "id", natRule_id),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -128,7 +128,18 @@ func resourceArmLoadBalancerProbeCreate(d *schema.ResourceData, meta interface{}
|
|||
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
|
||||
}
|
||||
|
||||
d.SetId(*read.ID)
|
||||
var createdProbe_id string
|
||||
for _, Probe := range *(*read.Properties).Probes {
|
||||
if *Probe.Name == d.Get("name").(string) {
|
||||
createdProbe_id = *Probe.ID
|
||||
}
|
||||
}
|
||||
|
||||
if createdProbe_id != "" {
|
||||
d.SetId(createdProbe_id)
|
||||
} else {
|
||||
return fmt.Errorf("Error can not find created probe id %s", createdProbe_id)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
|
||||
stateConf := &resource.StateChangeConf{
|
||||
|
@ -145,7 +156,7 @@ func resourceArmLoadBalancerProbeCreate(d *schema.ResourceData, meta interface{}
|
|||
}
|
||||
|
||||
func resourceArmLoadBalancerProbeRead(d *schema.ResourceData, meta interface{}) error {
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Id(), meta)
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Get("loadbalancer_id").(string), meta)
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package azurerm
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/network"
|
||||
|
@ -15,6 +16,11 @@ func TestAccAzureRMLoadBalancerProbe_basic(t *testing.T) {
|
|||
ri := acctest.RandInt()
|
||||
probeName := fmt.Sprintf("probe-%d", ri)
|
||||
|
||||
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
|
||||
probe_id := fmt.Sprintf(
|
||||
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/probes/%s",
|
||||
subscriptionID, ri, ri, probeName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -25,6 +31,8 @@ func TestAccAzureRMLoadBalancerProbe_basic(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
|
||||
testCheckAzureRMLoadBalancerProbeExists(probeName, &lb),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_lb_probe.test", "id", probe_id),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -149,7 +149,18 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})
|
|||
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
|
||||
}
|
||||
|
||||
d.SetId(*read.ID)
|
||||
var rule_id string
|
||||
for _, LoadBalancingRule := range *(*read.Properties).LoadBalancingRules {
|
||||
if *LoadBalancingRule.Name == d.Get("name").(string) {
|
||||
rule_id = *LoadBalancingRule.ID
|
||||
}
|
||||
}
|
||||
|
||||
if rule_id != "" {
|
||||
d.SetId(rule_id)
|
||||
} else {
|
||||
return fmt.Errorf("Error can not find created loadbalancer rule id %s", rule_id)
|
||||
}
|
||||
|
||||
log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
|
||||
stateConf := &resource.StateChangeConf{
|
||||
|
@ -166,7 +177,7 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})
|
|||
}
|
||||
|
||||
func resourceArmLoadBalancerRuleRead(d *schema.ResourceData, meta interface{}) error {
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Id(), meta)
|
||||
loadBalancer, exists, err := retrieveLoadBalancerById(d.Get("loadbalancer_id").(string), meta)
|
||||
if err != nil {
|
||||
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package azurerm
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/network"
|
||||
|
@ -63,6 +64,11 @@ func TestAccAzureRMLoadBalancerRule_basic(t *testing.T) {
|
|||
ri := acctest.RandInt()
|
||||
lbRuleName := fmt.Sprintf("LbRule-%s", acctest.RandStringFromCharSet(8, acctest.CharSetAlpha))
|
||||
|
||||
subscriptionID := os.Getenv("ARM_SUBSCRIPTION_ID")
|
||||
lbRule_id := fmt.Sprintf(
|
||||
"/subscriptions/%s/resourceGroups/acctestrg-%d/providers/Microsoft.Network/loadBalancers/arm-test-loadbalancer-%d/loadBalancingRules/%s",
|
||||
subscriptionID, ri, ri, lbRuleName)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
|
@ -73,6 +79,8 @@ func TestAccAzureRMLoadBalancerRule_basic(t *testing.T) {
|
|||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMLoadBalancerExists("azurerm_lb.test", &lb),
|
||||
testCheckAzureRMLoadBalancerRuleExists(lbRuleName, &lb),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_lb_rule.test", "id", lbRule_id),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue