Merge pull request #7627 from hashicorp/import-arm-nsg
provider/azurerm: Support Import of `azurerm_network_security_group`
This commit is contained in:
commit
9b3968aa14
|
@ -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"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -19,6 +19,9 @@ func resourceArmNetworkSecurityGroup() *schema.Resource {
|
|||
Read: resourceArmNetworkSecurityGroupRead,
|
||||
Update: resourceArmNetworkSecurityGroupCreate,
|
||||
Delete: resourceArmNetworkSecurityGroupDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
|
@ -200,6 +203,8 @@ func resourceArmNetworkSecurityGroupRead(d *schema.ResourceData, meta interface{
|
|||
d.Set("security_rule", flattenNetworkSecurityRules(resp.Properties.SecurityRules))
|
||||
}
|
||||
|
||||
d.Set("name", resp.Name)
|
||||
d.Set("location", resp.Location)
|
||||
flattenAndSetTags(d, resp.Tags)
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue