Merge pull request #7625 from hashicorp/import-arm-sqlfirewall_rule

provider/azurerm: Support Import of `azurerm_sql_firewall_rule`
This commit is contained in:
James Nugent 2016-07-13 09:42:12 -06:00 committed by GitHub
commit e506213cc8
2 changed files with 38 additions and 0 deletions

View File

@ -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"},
},
},
})
}

View File

@ -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)