Fix id of azurerm_lb_backend_address_pool, azurerm_lb_rule, azurerm_lb_nat_rule, azurerm_lb_nat_pool.

This commit is contained in:
Andreas Kyrris 2016-10-17 18:21:30 +01:00
parent 4a22fa0438
commit 7b133ad356
4 changed files with 52 additions and 8 deletions

View File

@ -100,7 +100,18 @@ func resourceArmLoadBalancerBackendAddressPoolCreate(d *schema.ResourceData, met
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup) return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
} }
d.SetId(*read.ID) var pool_id string
for _, element := range *(*read.Properties).BackendAddressPools {
if *element.Name == d.Get("name").(string) {
pool_id = *element.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) log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
@ -117,7 +128,7 @@ func resourceArmLoadBalancerBackendAddressPoolCreate(d *schema.ResourceData, met
} }
func resourceArmLoadBalancerBackendAddressPoolRead(d *schema.ResourceData, meta interface{}) error { 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 { if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err) return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
} }

View File

@ -122,7 +122,18 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup) return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
} }
d.SetId(*read.ID) var natPool_id string
for _, element := range *(*read.Properties).InboundNatPools {
if *element.Name == d.Get("name").(string) {
natPool_id = *element.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) log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
@ -139,7 +150,7 @@ func resourceArmLoadBalancerNatPoolCreate(d *schema.ResourceData, meta interface
} }
func resourceArmLoadBalancerNatPoolRead(d *schema.ResourceData, meta interface{}) error { 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 { if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err) return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
} }

View File

@ -122,7 +122,18 @@ func resourceArmLoadBalancerNatRuleCreate(d *schema.ResourceData, meta interface
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup) return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
} }
d.SetId(*read.ID) var natRule_id string
for _, element := range *(*read.Properties).InboundNatRules {
if *element.Name == d.Get("name").(string) {
natRule_id = *element.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) log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
@ -139,7 +150,7 @@ func resourceArmLoadBalancerNatRuleCreate(d *schema.ResourceData, meta interface
} }
func resourceArmLoadBalancerNatRuleRead(d *schema.ResourceData, meta interface{}) error { 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 { if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err) return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
} }

View File

@ -149,7 +149,18 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup) return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
} }
d.SetId(*read.ID) var rule_id string
for _, element := range *(*read.Properties).LoadBalancingRules {
if *element.Name == d.Get("name").(string) {
rule_id = *element.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) log.Printf("[DEBUG] Waiting for LoadBalancer (%s) to become available", loadBalancerName)
stateConf := &resource.StateChangeConf{ stateConf := &resource.StateChangeConf{
@ -166,7 +177,7 @@ func resourceArmLoadBalancerRuleCreate(d *schema.ResourceData, meta interface{})
} }
func resourceArmLoadBalancerRuleRead(d *schema.ResourceData, meta interface{}) error { 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 { if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err) return errwrap.Wrapf("Error Getting LoadBalancer By ID {{err}}", err)
} }