provider/azurerm: Support Import of `azurerm_sql_firewall_rule`

```
% make testacc TEST=./builtin/providers/azurerm  TESTARGS='-run=TestAccAzureRMSqlFirewallRule_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMSqlFirewallRule_ -timeout 120m
=== RUN   TestAccAzureRMSqlFirewallRule_importBasic
--- PASS: TestAccAzureRMSqlFirewallRule_importBasic (146.88s)
=== RUN   TestAccAzureRMSqlFirewallRule_basic
--- PASS: TestAccAzureRMSqlFirewallRule_basic (154.34s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
301.231s
```
This commit is contained in:
stack72 2016-07-13 12:53:24 +01:00
parent 9018e073fb
commit 5cd908e748
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
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)