Merge pull request #7627 from hashicorp/import-arm-nsg

provider/azurerm: Support Import of `azurerm_network_security_group`
This commit is contained in:
James Nugent 2016-07-13 09:41:28 -06:00 committed by GitHub
commit 9b3968aa14
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package azurerm
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMNetworkSecurityGroup_importBasic(t *testing.T) {
resourceName := "azurerm_network_security_group.test"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMNetworkSecurityGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAzureRMNetworkSecurityGroup_basic,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"resource_group_name"},
},
},
})
}

View File

@ -19,6 +19,9 @@ func resourceArmNetworkSecurityGroup() *schema.Resource {
Read: resourceArmNetworkSecurityGroupRead, Read: resourceArmNetworkSecurityGroupRead,
Update: resourceArmNetworkSecurityGroupCreate, Update: resourceArmNetworkSecurityGroupCreate,
Delete: resourceArmNetworkSecurityGroupDelete, Delete: resourceArmNetworkSecurityGroupDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": { "name": {
@ -200,6 +203,8 @@ func resourceArmNetworkSecurityGroupRead(d *schema.ResourceData, meta interface{
d.Set("security_rule", flattenNetworkSecurityRules(resp.Properties.SecurityRules)) d.Set("security_rule", flattenNetworkSecurityRules(resp.Properties.SecurityRules))
} }
d.Set("name", resp.Name)
d.Set("location", resp.Location)
flattenAndSetTags(d, resp.Tags) flattenAndSetTags(d, resp.Tags)
return nil return nil