mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #7630 from hashicorp/import-arm-nsr
provider/azurerm: Support Import `azurerm_network_security_rule`
This commit is contained in:
commit
3f80eb40ee
@ -0,0 +1,29 @@
|
||||
package azurerm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAzureRMNetworkSecurityRule_importBasic(t *testing.T) {
|
||||
resourceName := "azurerm_network_security_rule.test"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMNetworkSecurityRuleDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAzureRMNetworkSecurityRule_basic,
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateVerifyIgnore: []string{"resource_group_name", "network_security_group_name"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
@ -14,6 +14,9 @@ func resourceArmNetworkSecurityRule() *schema.Resource {
|
||||
Read: resourceArmNetworkSecurityRuleRead,
|
||||
Update: resourceArmNetworkSecurityRuleCreate,
|
||||
Delete: resourceArmNetworkSecurityRuleDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
@ -180,6 +183,17 @@ func resourceArmNetworkSecurityRuleRead(d *schema.ResourceData, meta interface{}
|
||||
return fmt.Errorf("Error making Read request on Azure Network Security Rule %s: %s", sgRuleName, err)
|
||||
}
|
||||
|
||||
d.Set("access", resp.Properties.Access)
|
||||
d.Set("destination_address_prefix", resp.Properties.DestinationAddressPrefix)
|
||||
d.Set("destination_port_range", resp.Properties.DestinationPortRange)
|
||||
d.Set("direction", resp.Properties.Direction)
|
||||
d.Set("description", resp.Properties.Description)
|
||||
d.Set("name", resp.Name)
|
||||
d.Set("priority", resp.Properties.Priority)
|
||||
d.Set("protocol", resp.Properties.Protocol)
|
||||
d.Set("source_address_prefix", resp.Properties.SourceAddressPrefix)
|
||||
d.Set("source_port_range", resp.Properties.SourcePortRange)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user