diff --git a/builtin/providers/azurerm/import_arm_network_security_rule_test.go b/builtin/providers/azurerm/import_arm_network_security_rule_test.go new file mode 100644 index 0000000000..8e871767e3 --- /dev/null +++ b/builtin/providers/azurerm/import_arm_network_security_rule_test.go @@ -0,0 +1,29 @@ +package azurerm + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMNetworkSecurityRule_importBasic(t *testing.T) { + resourceName := "azurerm_network_security_rule.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMNetworkSecurityRuleDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAzureRMNetworkSecurityRule_basic, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"resource_group_name", "network_security_group_name"}, + }, + }, + }) +} diff --git a/builtin/providers/azurerm/resource_arm_network_security_rule.go b/builtin/providers/azurerm/resource_arm_network_security_rule.go index 050781cd31..eb5b4f2635 100644 --- a/builtin/providers/azurerm/resource_arm_network_security_rule.go +++ b/builtin/providers/azurerm/resource_arm_network_security_rule.go @@ -14,6 +14,9 @@ func resourceArmNetworkSecurityRule() *schema.Resource { Read: resourceArmNetworkSecurityRuleRead, Update: resourceArmNetworkSecurityRuleCreate, Delete: resourceArmNetworkSecurityRuleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": { @@ -180,6 +183,17 @@ func resourceArmNetworkSecurityRuleRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("Error making Read request on Azure Network Security Rule %s: %s", sgRuleName, err) } + d.Set("access", resp.Properties.Access) + d.Set("destination_address_prefix", resp.Properties.DestinationAddressPrefix) + d.Set("destination_port_range", resp.Properties.DestinationPortRange) + d.Set("direction", resp.Properties.Direction) + d.Set("description", resp.Properties.Description) + d.Set("name", resp.Name) + d.Set("priority", resp.Properties.Priority) + d.Set("protocol", resp.Properties.Protocol) + d.Set("source_address_prefix", resp.Properties.SourceAddressPrefix) + d.Set("source_port_range", resp.Properties.SourcePortRange) + return nil }