From f79d951524c804437a8df9def44f1aa1bed5426e Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 7 Jan 2016 22:32:49 +0000 Subject: [PATCH] Rename the AzureRM Security Group to AzureRM Network Security Group --- builtin/providers/azurerm/provider.go | 10 +-- ...=> resource_arm_network_security_group.go} | 52 ++++++++-------- ...source_arm_network_security_group_test.go} | 62 +++++++++---------- ...n => network_security_group.html.markdown} | 6 +- website/source/layouts/azurerm.erb | 4 +- 5 files changed, 67 insertions(+), 67 deletions(-) rename builtin/providers/azurerm/{resource_arm_security_group.go => resource_arm_network_security_group.go} (77%) rename builtin/providers/azurerm/{resource_arm_security_group_test.go => resource_arm_network_security_group_test.go} (65%) rename website/source/docs/providers/azurerm/r/{security_group.html.markdown => network_security_group.html.markdown} (93%) diff --git a/builtin/providers/azurerm/provider.go b/builtin/providers/azurerm/provider.go index 1642c64d3..0e989a15c 100644 --- a/builtin/providers/azurerm/provider.go +++ b/builtin/providers/azurerm/provider.go @@ -39,11 +39,11 @@ func Provider() terraform.ResourceProvider { }, ResourcesMap: map[string]*schema.Resource{ - "azurerm_resource_group": resourceArmResourceGroup(), - "azurerm_virtual_network": resourceArmVirtualNetwork(), - "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), - "azurerm_availability_set": resourceArmAvailabilitySet(), - "azurerm_security_group": resourceArmSecurityGroup(), + "azurerm_resource_group": resourceArmResourceGroup(), + "azurerm_virtual_network": resourceArmVirtualNetwork(), + "azurerm_local_network_gateway": resourceArmLocalNetworkGateway(), + "azurerm_availability_set": resourceArmAvailabilitySet(), + "azurerm_network_security_group": resourceArmNetworkSecurityGroup(), }, ConfigureFunc: providerConfigure, diff --git a/builtin/providers/azurerm/resource_arm_security_group.go b/builtin/providers/azurerm/resource_arm_network_security_group.go similarity index 77% rename from builtin/providers/azurerm/resource_arm_security_group.go rename to builtin/providers/azurerm/resource_arm_network_security_group.go index e523ea2f6..c70522313 100644 --- a/builtin/providers/azurerm/resource_arm_security_group.go +++ b/builtin/providers/azurerm/resource_arm_network_security_group.go @@ -15,12 +15,12 @@ import ( "github.com/hashicorp/terraform/helper/schema" ) -func resourceArmSecurityGroup() *schema.Resource { +func resourceArmNetworkSecurityGroup() *schema.Resource { return &schema.Resource{ - Create: resourceArmSecurityGroupCreate, - Read: resourceArmSecurityGroupRead, - Update: resourceArmSecurityGroupCreate, - Delete: resourceArmSecurityGroupDelete, + Create: resourceArmNetworkSecurityGroupCreate, + Read: resourceArmNetworkSecurityGroupRead, + Update: resourceArmNetworkSecurityGroupCreate, + Delete: resourceArmNetworkSecurityGroupDelete, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -60,7 +60,7 @@ func resourceArmSecurityGroup() *schema.Resource { value := v.(string) if len(value) > 140 { errors = append(errors, fmt.Errorf( - "The security rule description can be no longer than 140 chars")) + "The network security rule description can be no longer than 140 chars")) } return }, @@ -69,7 +69,7 @@ func resourceArmSecurityGroup() *schema.Resource { "protocol": &schema.Schema{ Type: schema.TypeString, Required: true, - ValidateFunc: validateSecurityRuleProtocol, + ValidateFunc: validateNetworkSecurityRuleProtocol, }, "source_port_range": &schema.Schema{ @@ -95,7 +95,7 @@ func resourceArmSecurityGroup() *schema.Resource { "access": &schema.Schema{ Type: schema.TypeString, Required: true, - ValidateFunc: validateSecurityRuleAccess, + ValidateFunc: validateNetworkSecurityRuleAccess, }, "priority": &schema.Schema{ @@ -114,17 +114,17 @@ func resourceArmSecurityGroup() *schema.Resource { "direction": &schema.Schema{ Type: schema.TypeString, Required: true, - ValidateFunc: validateSecurityRuleDirection, + ValidateFunc: validateNetworkSecurityRuleDirection, }, }, }, - Set: resourceArmSecurityGroupRuleHash, + Set: resourceArmNetworkSecurityGroupRuleHash, }, }, } } -func resourceArmSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error { +func resourceArmNetworkSecurityGroupCreate(d *schema.ResourceData, meta interface{}) error { client := meta.(*ArmClient) secClient := client.secGroupClient @@ -134,7 +134,7 @@ func resourceArmSecurityGroupCreate(d *schema.ResourceData, meta interface{}) er sgRules, sgErr := expandAzureRmSecurityGroupRules(d) if sgErr != nil { - return fmt.Errorf("Error Building list of Security Group Rules: %s", sgErr) + return fmt.Errorf("Error Building list of Network Security Group Rules: %s", sgErr) } sg := network.SecurityGroup{ @@ -152,7 +152,7 @@ func resourceArmSecurityGroupCreate(d *schema.ResourceData, meta interface{}) er d.SetId(*resp.ID) - log.Printf("[DEBUG] Waiting for Security Group (%s) to become available", name) + log.Printf("[DEBUG] Waiting for Network Security Group (%s) to become available", name) stateConf := &resource.StateChangeConf{ Pending: []string{"Accepted", "Updating"}, Target: "Succeeded", @@ -160,13 +160,13 @@ func resourceArmSecurityGroupCreate(d *schema.ResourceData, meta interface{}) er Timeout: 10 * time.Minute, } if _, err := stateConf.WaitForState(); err != nil { - return fmt.Errorf("Error waiting for Securty Group (%s) to become available: %s", name, err) + return fmt.Errorf("Error waiting for Network Securty Group (%s) to become available: %s", name, err) } - return resourceArmSecurityGroupRead(d, meta) + return resourceArmNetworkSecurityGroupRead(d, meta) } -func resourceArmSecurityGroupRead(d *schema.ResourceData, meta interface{}) error { +func resourceArmNetworkSecurityGroupRead(d *schema.ResourceData, meta interface{}) error { secGroupClient := meta.(*ArmClient).secGroupClient id, err := parseAzureResourceID(d.Id()) @@ -182,13 +182,13 @@ func resourceArmSecurityGroupRead(d *schema.ResourceData, meta interface{}) erro return nil } if err != nil { - return fmt.Errorf("Error making Read request on Azure Security Group %s: %s", name, err) + return fmt.Errorf("Error making Read request on Azure Network Security Group %s: %s", name, err) } return nil } -func resourceArmSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error { +func resourceArmNetworkSecurityGroupDelete(d *schema.ResourceData, meta interface{}) error { secGroupClient := meta.(*ArmClient).secGroupClient id, err := parseAzureResourceID(d.Id()) @@ -203,7 +203,7 @@ func resourceArmSecurityGroupDelete(d *schema.ResourceData, meta interface{}) er return err } -func resourceArmSecurityGroupRuleHash(v interface{}) int { +func resourceArmNetworkSecurityGroupRuleHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m["protocol"].(string))) @@ -222,7 +222,7 @@ func securityGroupStateRefreshFunc(client *ArmClient, resourceGroupName string, return func() (interface{}, string, error) { res, err := client.secGroupClient.Get(resourceGroupName, securityGroupName) if err != nil { - return nil, "", fmt.Errorf("Error issuing read request in securityGroupStateRefreshFunc to Azure ARM for security group '%s' (RG: '%s'): %s", securityGroupName, resourceGroupName, err) + return nil, "", fmt.Errorf("Error issuing read request in securityGroupStateRefreshFunc to Azure ARM for network security group '%s' (RG: '%s'): %s", securityGroupName, resourceGroupName, err) } return res, *res.Properties.ProvisioningState, nil @@ -269,7 +269,7 @@ func expandAzureRmSecurityGroupRules(d *schema.ResourceData) ([]network.Security return rules, nil } -func validateSecurityRuleProtocol(v interface{}, k string) (ws []string, errors []error) { +func validateNetworkSecurityRuleProtocol(v interface{}, k string) (ws []string, errors []error) { value := strings.ToLower(v.(string)) viewTypes := map[string]bool{ "tcp": true, @@ -278,12 +278,12 @@ func validateSecurityRuleProtocol(v interface{}, k string) (ws []string, errors } if !viewTypes[value] { - errors = append(errors, fmt.Errorf("Security Rule Protocol can only be Tcp, Udp or *")) + errors = append(errors, fmt.Errorf("Network Security Rule Protocol can only be Tcp, Udp or *")) } return } -func validateSecurityRuleAccess(v interface{}, k string) (ws []string, errors []error) { +func validateNetworkSecurityRuleAccess(v interface{}, k string) (ws []string, errors []error) { value := strings.ToLower(v.(string)) viewTypes := map[string]bool{ "allow": true, @@ -291,12 +291,12 @@ func validateSecurityRuleAccess(v interface{}, k string) (ws []string, errors [] } if !viewTypes[value] { - errors = append(errors, fmt.Errorf("Security Rule Access can only be Allow or Deny")) + errors = append(errors, fmt.Errorf("Network Security Rule Access can only be Allow or Deny")) } return } -func validateSecurityRuleDirection(v interface{}, k string) (ws []string, errors []error) { +func validateNetworkSecurityRuleDirection(v interface{}, k string) (ws []string, errors []error) { value := strings.ToLower(v.(string)) viewTypes := map[string]bool{ "inbound": true, @@ -304,7 +304,7 @@ func validateSecurityRuleDirection(v interface{}, k string) (ws []string, errors } if !viewTypes[value] { - errors = append(errors, fmt.Errorf("Security Rule Directions can only be Inbound or Outbound")) + errors = append(errors, fmt.Errorf("Network Security Rule Directions can only be Inbound or Outbound")) } return } diff --git a/builtin/providers/azurerm/resource_arm_security_group_test.go b/builtin/providers/azurerm/resource_arm_network_security_group_test.go similarity index 65% rename from builtin/providers/azurerm/resource_arm_security_group_test.go rename to builtin/providers/azurerm/resource_arm_network_security_group_test.go index 8431399e0..11dd75d7c 100644 --- a/builtin/providers/azurerm/resource_arm_security_group_test.go +++ b/builtin/providers/azurerm/resource_arm_network_security_group_test.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform/terraform" ) -func TestResourceAzureRMSecurityGroupProtocol_validation(t *testing.T) { +func TestResourceAzureRMNetworkSecurityGroupProtocol_validation(t *testing.T) { cases := []struct { Value string ErrCount int @@ -41,15 +41,15 @@ func TestResourceAzureRMSecurityGroupProtocol_validation(t *testing.T) { } for _, tc := range cases { - _, errors := validateSecurityRuleProtocol(tc.Value, "azurerm_security_group") + _, errors := validateNetworkSecurityRuleProtocol(tc.Value, "azurerm_network_security_group") if len(errors) != tc.ErrCount { - t.Fatalf("Expected the Azure RM Security Group protocol to trigger a validation error") + t.Fatalf("Expected the Azure RM Network Security Group protocol to trigger a validation error") } } } -func TestResourceAzureRMSecurityGroupAccess_validation(t *testing.T) { +func TestResourceAzureRMNetworkSecurityGroupAccess_validation(t *testing.T) { cases := []struct { Value string ErrCount int @@ -77,15 +77,15 @@ func TestResourceAzureRMSecurityGroupAccess_validation(t *testing.T) { } for _, tc := range cases { - _, errors := validateSecurityRuleAccess(tc.Value, "azurerm_security_group") + _, errors := validateNetworkSecurityRuleAccess(tc.Value, "azurerm_network_security_group") if len(errors) != tc.ErrCount { - t.Fatalf("Expected the Azure RM Security Group access to trigger a validation error") + t.Fatalf("Expected the Azure RM Network Security Group access to trigger a validation error") } } } -func TestResourceAzureRMSecurityGroupDirection_validation(t *testing.T) { +func TestResourceAzureRMNetworkSecurityGroupDirection_validation(t *testing.T) { cases := []struct { Value string ErrCount int @@ -113,60 +113,60 @@ func TestResourceAzureRMSecurityGroupDirection_validation(t *testing.T) { } for _, tc := range cases { - _, errors := validateSecurityRuleDirection(tc.Value, "azurerm_security_group") + _, errors := validateNetworkSecurityRuleDirection(tc.Value, "azurerm_network_security_group") if len(errors) != tc.ErrCount { - t.Fatalf("Expected the Azure RM Security Group direction to trigger a validation error") + t.Fatalf("Expected the Azure RM Network Security Group direction to trigger a validation error") } } } -func TestAccAzureRMSecurityGroup_basic(t *testing.T) { +func TestAccAzureRMNetworkSecurityGroup_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMSecurityGroupDestroy, + CheckDestroy: testCheckAzureRMNetworkSecurityGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAzureRMSecurityGroup_basic, + Config: testAccAzureRMNetworkSecurityGroup_basic, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMSecurityGroupExists("azurerm_security_group.test"), + testCheckAzureRMNetworkSecurityGroupExists("azurerm_network_security_group.test"), ), }, }, }) } -func TestAccAzureRMSecurityGroup_addingExtraRules(t *testing.T) { +func TestAccAzureRMNetworkSecurityGroup_addingExtraRules(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testCheckAzureRMSecurityGroupDestroy, + CheckDestroy: testCheckAzureRMNetworkSecurityGroupDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAzureRMSecurityGroup_basic, + Config: testAccAzureRMNetworkSecurityGroup_basic, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMSecurityGroupExists("azurerm_security_group.test"), + testCheckAzureRMNetworkSecurityGroupExists("azurerm_network_security_group.test"), resource.TestCheckResourceAttr( - "azurerm_security_group.test", "security_rule.#", "1"), + "azurerm_network_security_group.test", "security_rule.#", "1"), ), }, resource.TestStep{ - Config: testAccAzureRMSecurityGroup_anotherRule, + Config: testAccAzureRMNetworkSecurityGroup_anotherRule, Check: resource.ComposeTestCheckFunc( - testCheckAzureRMSecurityGroupExists("azurerm_security_group.test"), + testCheckAzureRMNetworkSecurityGroupExists("azurerm_network_security_group.test"), resource.TestCheckResourceAttr( - "azurerm_security_group.test", "security_rule.#", "2"), + "azurerm_network_security_group.test", "security_rule.#", "2"), ), }, }, }) } -func testCheckAzureRMSecurityGroupExists(name string) resource.TestCheckFunc { +func testCheckAzureRMNetworkSecurityGroupExists(name string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[name] @@ -177,7 +177,7 @@ func testCheckAzureRMSecurityGroupExists(name string) resource.TestCheckFunc { sgName := rs.Primary.Attributes["name"] resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] if !hasResourceGroup { - return fmt.Errorf("Bad: no resource group found in state for security group: %s", sgName) + return fmt.Errorf("Bad: no resource group found in state for network security group: %s", sgName) } conn := testAccProvider.Meta().(*ArmClient).secGroupClient @@ -188,18 +188,18 @@ func testCheckAzureRMSecurityGroupExists(name string) resource.TestCheckFunc { } if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: Security Group %q (resource group: %q) does not exist", name, resourceGroup) + return fmt.Errorf("Bad: Network Security Group %q (resource group: %q) does not exist", name, resourceGroup) } return nil } } -func testCheckAzureRMSecurityGroupDestroy(s *terraform.State) error { +func testCheckAzureRMNetworkSecurityGroupDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*ArmClient).secGroupClient for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_security_group" { + if rs.Type != "azurerm_network_security_group" { continue } @@ -213,20 +213,20 @@ func testCheckAzureRMSecurityGroupDestroy(s *terraform.State) error { } if resp.StatusCode != http.StatusNotFound { - return fmt.Errorf("Security Group still exists:\n%#v", resp.Properties) + return fmt.Errorf("Network Security Group still exists:\n%#v", resp.Properties) } } return nil } -var testAccAzureRMSecurityGroup_basic = ` +var testAccAzureRMNetworkSecurityGroup_basic = ` resource "azurerm_resource_group" "test" { name = "acceptanceTestResourceGroup1" location = "West US" } -resource "azurerm_security_group" "test" { +resource "azurerm_network_security_group" "test" { name = "acceptanceTestSecurityGroup1" location = "West US" resource_group_name = "${azurerm_resource_group.test.name}" @@ -245,13 +245,13 @@ resource "azurerm_security_group" "test" { } ` -var testAccAzureRMSecurityGroup_anotherRule = ` +var testAccAzureRMNetworkSecurityGroup_anotherRule = ` resource "azurerm_resource_group" "test" { name = "acceptanceTestResourceGroup1" location = "West US" } -resource "azurerm_security_group" "test" { +resource "azurerm_network_security_group" "test" { name = "acceptanceTestSecurityGroup1" location = "West US" resource_group_name = "${azurerm_resource_group.test.name}" diff --git a/website/source/docs/providers/azurerm/r/security_group.html.markdown b/website/source/docs/providers/azurerm/r/network_security_group.html.markdown similarity index 93% rename from website/source/docs/providers/azurerm/r/security_group.html.markdown rename to website/source/docs/providers/azurerm/r/network_security_group.html.markdown index f138f4c12..8a5a29e1f 100644 --- a/website/source/docs/providers/azurerm/r/security_group.html.markdown +++ b/website/source/docs/providers/azurerm/r/network_security_group.html.markdown @@ -1,7 +1,7 @@ --- layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_security_group" -sidebar_current: "docs-azurerm-resource-security-group" +page_title: "Azure Resource Manager: azurerm_network_security_group" +sidebar_current: "docs-azurerm-resource-network-security-group" description: |- Create a network security group that contains a list of network security rules. Network security groups enable inbound or outbound traffic to be enabled or denied. --- @@ -18,7 +18,7 @@ resource "azurerm_resource_group" "test" { location = "West US" } -resource "azurerm_security_group" "test" { +resource "azurerm_network_security_group" "test" { name = "acceptanceTestSecurityGroup1" location = "West US" resource_group_name = "${azurerm_resource_group.test.name}" diff --git a/website/source/layouts/azurerm.erb b/website/source/layouts/azurerm.erb index 77a0987a4..90cb8fcbe 100644 --- a/website/source/layouts/azurerm.erb +++ b/website/source/layouts/azurerm.erb @@ -29,8 +29,8 @@ azurerm_availability_set - > - azurerm_security_group + > + azurerm_network_security_group