Skip to content

Commit

Permalink
Merge pull request #2558 from terraform-providers/network/security_ru…
Browse files Browse the repository at this point in the history
…le-appid

azurerm_network_security_rule: fixed app id read & import
  • Loading branch information
katbyte authored Dec 21, 2018
2 parents a2078f8 + c334b0c commit e38a233
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions azurerm/resource_arm_network_security_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit e38a233

Please sign in to comment.