From c334b0cf29048161fb88536a3015b88a13939821 Mon Sep 17 00:00:00 2001 From: kt Date: Thu, 20 Dec 2018 14:43:27 -0800 Subject: [PATCH] azurerm_network_security_rule: fixed app id read & import --- azurerm/resource_arm_network_security_rule.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/azurerm/resource_arm_network_security_rule.go b/azurerm/resource_arm_network_security_rule.go index 184a590665a1..fb3a08e3da5e 100644 --- a/azurerm/resource_arm_network_security_rule.go +++ b/azurerm/resource_arm_network_security_rule.go @@ -314,6 +314,14 @@ func resourceArmNetworkSecurityRuleRead(d *schema.ResourceData, meta interface{} d.Set("access", string(props.Access)) d.Set("priority", int(*props.Priority)) d.Set("direction", string(props.Direction)) + + if err := d.Set("source_application_security_group_ids", flattenApplicationSecurityGroupIds(props.SourceApplicationSecurityGroups)); err != nil { + return fmt.Errorf("Error setting `source_application_security_group_ids`: %+v", err) + } + + if err := d.Set("destination_application_security_group_ids", flattenApplicationSecurityGroupIds(props.DestinationApplicationSecurityGroups)); err != nil { + return fmt.Errorf("Error setting `source_application_security_group_ids`: %+v", err) + } } return nil @@ -345,3 +353,15 @@ func resourceArmNetworkSecurityRuleDelete(d *schema.ResourceData, meta interface return nil } + +func flattenApplicationSecurityGroupIds(groups *[]network.ApplicationSecurityGroup) []string { + ids := make([]string, 0) + + if groups != nil { + for _, v := range *groups { + ids = append(ids, *v.ID) + } + } + + return ids +}