diff --git a/builtin/providers/azurerm/import_arm_sql_firewall_rule_test.go b/builtin/providers/azurerm/import_arm_sql_firewall_rule_test.go new file mode 100644 index 000000000..efdb3c131 --- /dev/null +++ b/builtin/providers/azurerm/import_arm_sql_firewall_rule_test.go @@ -0,0 +1,34 @@ +package azurerm + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform/helper/acctest" + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAzureRMSqlFirewallRule_importBasic(t *testing.T) { + resourceName := "azurerm_sql_firewall_rule.test" + + ri := acctest.RandInt() + config := fmt.Sprintf(testAccAzureRMSqlFirewallRule_basic, ri, ri, ri) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testCheckAzureRMSqlFirewallRuleDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: config, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"resource_group_name", "server_name"}, + }, + }, + }) +} diff --git a/builtin/providers/azurerm/resource_arm_sql_firewall_rule.go b/builtin/providers/azurerm/resource_arm_sql_firewall_rule.go index f58238975..1ae4db4cc 100644 --- a/builtin/providers/azurerm/resource_arm_sql_firewall_rule.go +++ b/builtin/providers/azurerm/resource_arm_sql_firewall_rule.go @@ -15,6 +15,9 @@ func resourceArmSqlFirewallRule() *schema.Resource { Read: resourceArmSqlFirewallRuleRead, Update: resourceArmSqlFirewallRuleCreate, Delete: resourceArmSqlFirewallRuleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -109,6 +112,7 @@ func resourceArmSqlFirewallRuleRead(d *schema.ResourceData, meta interface{}) er resp := readResponse.Parsed.(*sql.GetFirewallRuleResponse) + d.Set("name", resp.Name) d.Set("start_ip_address", resp.StartIPAddress) d.Set("end_ip_address", resp.EndIPAddress)