-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provider/azurerm Fix multiple loadbalancer resource IDs #9401
Changes from all commits
25794f6
c1d4397
f4980bf
4bf1985
a0ad874
e63d120
4a22fa0
7b133ad
da12ed6
182ebf3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we expose this via the provider? |
||
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), | ||
), | ||
}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could use retrieveLoadBalancerById() here again then findLoadBalancerProbeByName(), but it's another call to the API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine to read the response here and avoid the additional round trip. |
||
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) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadbalacner
=>LoadBalancer