provider/azurerm: Fix azurerm_route_table

```
HTTP_PROXY=http://localhost:8888 make testacc TEST=./builtin/providers/azurerm TESTARGS="-run TestAccAzureRMRouteTable"
==> Checking that code complies with gofmt requirements...
/Users/James/Code/go/bin/stringer
go generate $(go list ./... | grep -v /vendor/)
2016/06/01 18:19:00 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMRouteTable -timeout 120m
=== RUN   TestAccAzureRMRouteTable_basic
--- PASS: TestAccAzureRMRouteTable_basic (76.52s)
=== RUN   TestAccAzureRMRouteTable_withTags
--- PASS: TestAccAzureRMRouteTable_withTags (92.15s)
=== RUN   TestAccAzureRMRouteTable_multipleRoutes
--- PASS: TestAccAzureRMRouteTable_multipleRoutes (98.14s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm 266.828s
```
This commit is contained in:
James Nugent 2016-06-01 18:24:40 -05:00
parent 5f45521795
commit 9b9ec7bb6c
3 changed files with 533 additions and 549 deletions

View File

@ -54,7 +54,7 @@ func Provider() terraform.ResourceProvider {
//"azurerm_network_security_rule": resourceArmNetworkSecurityRule(), //"azurerm_network_security_rule": resourceArmNetworkSecurityRule(),
"azurerm_public_ip": resourceArmPublicIp(), "azurerm_public_ip": resourceArmPublicIp(),
//"azurerm_route": resourceArmRoute(), //"azurerm_route": resourceArmRoute(),
//"azurerm_route_table": resourceArmRouteTable(), "azurerm_route_table": resourceArmRouteTable(),
"azurerm_storage_account": resourceArmStorageAccount(), "azurerm_storage_account": resourceArmStorageAccount(),
"azurerm_storage_blob": resourceArmStorageBlob(), "azurerm_storage_blob": resourceArmStorageBlob(),
"azurerm_storage_container": resourceArmStorageContainer(), "azurerm_storage_container": resourceArmStorageContainer(),

View File

@ -1,258 +1,242 @@
package azurerm package azurerm
//import ( import (
// "bytes" "bytes"
// "fmt" "fmt"
// "log" "log"
// "net/http" "net/http"
// "strings" "strings"
// "time"
// "github.com/Azure/azure-sdk-for-go/arm/network"
// "github.com/Azure/azure-sdk-for-go/arm/network" "github.com/hashicorp/terraform/helper/hashcode"
// "github.com/hashicorp/terraform/helper/hashcode" "github.com/hashicorp/terraform/helper/schema"
// "github.com/hashicorp/terraform/helper/resource" )
// "github.com/hashicorp/terraform/helper/schema"
//) func resourceArmRouteTable() *schema.Resource {
// return &schema.Resource{
//func resourceArmRouteTable() *schema.Resource { Create: resourceArmRouteTableCreate,
// return &schema.Resource{ Read: resourceArmRouteTableRead,
// Create: resourceArmRouteTableCreate, Update: resourceArmRouteTableCreate,
// Read: resourceArmRouteTableRead, Delete: resourceArmRouteTableDelete,
// Update: resourceArmRouteTableCreate,
// Delete: resourceArmRouteTableDelete, Schema: map[string]*schema.Schema{
// "name": {
// Schema: map[string]*schema.Schema{ Type: schema.TypeString,
// "name": &schema.Schema{ Required: true,
// Type: schema.TypeString, ForceNew: true,
// Required: true, },
// ForceNew: true,
// }, "location": {
// Type: schema.TypeString,
// "location": &schema.Schema{ Required: true,
// Type: schema.TypeString, ForceNew: true,
// Required: true, StateFunc: azureRMNormalizeLocation,
// ForceNew: true, },
// StateFunc: azureRMNormalizeLocation,
// }, "resource_group_name": {
// Type: schema.TypeString,
// "resource_group_name": &schema.Schema{ Required: true,
// Type: schema.TypeString, ForceNew: true,
// Required: true, },
// ForceNew: true,
// }, "route": {
// Type: schema.TypeSet,
// "route": &schema.Schema{ Optional: true,
// Type: schema.TypeSet, Computed: true,
// Optional: true, Elem: &schema.Resource{
// Computed: true, Schema: map[string]*schema.Schema{
// Elem: &schema.Resource{ "name": {
// Schema: map[string]*schema.Schema{ Type: schema.TypeString,
// "name": &schema.Schema{ Required: true,
// Type: schema.TypeString, },
// Required: true,
// }, "address_prefix": {
// Type: schema.TypeString,
// "address_prefix": &schema.Schema{ Required: true,
// Type: schema.TypeString, },
// Required: true,
// }, "next_hop_type": {
// Type: schema.TypeString,
// "next_hop_type": &schema.Schema{ Required: true,
// Type: schema.TypeString, ValidateFunc: validateRouteTableNextHopType,
// Required: true, },
// ValidateFunc: validateRouteTableNextHopType,
// }, "next_hop_in_ip_address": {
// Type: schema.TypeString,
// "next_hop_in_ip_address": &schema.Schema{ Optional: true,
// Type: schema.TypeString, Computed: true,
// Optional: true, },
// Computed: true, },
// }, },
// }, Set: resourceArmRouteTableRouteHash,
// }, },
// Set: resourceArmRouteTableRouteHash,
// }, "subnets": {
// Type: schema.TypeSet,
// "subnets": &schema.Schema{ Optional: true,
// Type: schema.TypeSet, Computed: true,
// Optional: true, Elem: &schema.Schema{Type: schema.TypeString},
// Computed: true, Set: schema.HashString,
// Elem: &schema.Schema{Type: schema.TypeString}, },
// Set: schema.HashString,
// }, "tags": tagsSchema(),
// },
// "tags": tagsSchema(), }
// }, }
// }
//} func resourceArmRouteTableCreate(d *schema.ResourceData, meta interface{}) error {
// client := meta.(*ArmClient)
//func resourceArmRouteTableCreate(d *schema.ResourceData, meta interface{}) error { routeTablesClient := client.routeTablesClient
// client := meta.(*ArmClient)
// routeTablesClient := client.routeTablesClient log.Printf("[INFO] preparing arguments for Azure ARM Route Table creation.")
//
// log.Printf("[INFO] preparing arguments for Azure ARM Route Table creation.") name := d.Get("name").(string)
// location := d.Get("location").(string)
// name := d.Get("name").(string) resGroup := d.Get("resource_group_name").(string)
// location := d.Get("location").(string) tags := d.Get("tags").(map[string]interface{})
// resGroup := d.Get("resource_group_name").(string)
// tags := d.Get("tags").(map[string]interface{}) routeSet := network.RouteTable{
// Name: &name,
// routeSet := network.RouteTable{ Location: &location,
// Name: &name, Tags: expandTags(tags),
// Location: &location, }
// Tags: expandTags(tags),
// } if _, ok := d.GetOk("route"); ok {
// properties := network.RouteTablePropertiesFormat{}
// if _, ok := d.GetOk("route"); ok { routes, routeErr := expandAzureRmRouteTableRoutes(d)
// properties := network.RouteTablePropertiesFormat{} if routeErr != nil {
// routes, routeErr := expandAzureRmRouteTableRoutes(d) return fmt.Errorf("Error Building list of Route Table Routes: %s", routeErr)
// if routeErr != nil { }
// return fmt.Errorf("Error Building list of Route Table Routes: %s", routeErr) if len(routes) > 0 {
// } routeSet.Properties = &properties
// if len(routes) > 0 { }
// routeSet.Properties = &properties
// } }
//
// } _, err := routeTablesClient.CreateOrUpdate(resGroup, name, routeSet, make(chan struct{}))
// if err != nil {
// resp, err := routeTablesClient.CreateOrUpdate(resGroup, name, routeSet) return err
// if err != nil { }
// return err
// } read, err := routeTablesClient.Get(resGroup, name, "")
// if err != nil {
// d.SetId(*resp.ID) return err
// }
// log.Printf("[DEBUG] Waiting for Route Table (%s) to become available", name) if read.ID == nil {
// stateConf := &resource.StateChangeConf{ return fmt.Errorf("Cannot read Route Table %s (resource group %s) ID", name, resGroup)
// Pending: []string{"Accepted", "Updating"}, }
// Target: []string{"Succeeded"},
// Refresh: routeTableStateRefreshFunc(client, resGroup, name), d.SetId(*read.ID)
// Timeout: 10 * time.Minute,
// } return resourceArmRouteTableRead(d, meta)
// if _, err := stateConf.WaitForState(); err != nil { }
// return fmt.Errorf("Error waiting forRoute Table (%s) to become available: %s", name, err)
// } func resourceArmRouteTableRead(d *schema.ResourceData, meta interface{}) error {
// routeTablesClient := meta.(*ArmClient).routeTablesClient
// return resourceArmRouteTableRead(d, meta)
//} id, err := parseAzureResourceID(d.Id())
// if err != nil {
//func resourceArmRouteTableRead(d *schema.ResourceData, meta interface{}) error { return err
// routeTablesClient := meta.(*ArmClient).routeTablesClient }
// resGroup := id.ResourceGroup
// id, err := parseAzureResourceID(d.Id()) name := id.Path["routeTables"]
// if err != nil {
// return err resp, err := routeTablesClient.Get(resGroup, name, "")
// } if resp.StatusCode == http.StatusNotFound {
// resGroup := id.ResourceGroup d.SetId("")
// name := id.Path["routeTables"] return nil
// }
// resp, err := routeTablesClient.Get(resGroup, name, "") if err != nil {
// if resp.StatusCode == http.StatusNotFound { return fmt.Errorf("Error making Read request on Azure Route Table %s: %s", name, err)
// d.SetId("") }
// return nil
// } if resp.Properties.Subnets != nil {
// if err != nil { if len(*resp.Properties.Subnets) > 0 {
// return fmt.Errorf("Error making Read request on Azure Route Table %s: %s", name, err) subnets := make([]string, 0, len(*resp.Properties.Subnets))
// } for _, subnet := range *resp.Properties.Subnets {
// id := subnet.ID
// if resp.Properties.Subnets != nil { subnets = append(subnets, *id)
// if len(*resp.Properties.Subnets) > 0 { }
// subnets := make([]string, 0, len(*resp.Properties.Subnets))
// for _, subnet := range *resp.Properties.Subnets { if err := d.Set("subnets", subnets); err != nil {
// id := subnet.ID return err
// subnets = append(subnets, *id) }
// } }
// }
// if err := d.Set("subnets", subnets); err != nil {
// return err flattenAndSetTags(d, resp.Tags)
// }
// } return nil
// } }
//
// flattenAndSetTags(d, resp.Tags) func resourceArmRouteTableDelete(d *schema.ResourceData, meta interface{}) error {
// routeTablesClient := meta.(*ArmClient).routeTablesClient
// return nil
//} id, err := parseAzureResourceID(d.Id())
// if err != nil {
//func resourceArmRouteTableDelete(d *schema.ResourceData, meta interface{}) error { return err
// routeTablesClient := meta.(*ArmClient).routeTablesClient }
// resGroup := id.ResourceGroup
// id, err := parseAzureResourceID(d.Id()) name := id.Path["routeTables"]
// if err != nil {
// return err _, err = routeTablesClient.Delete(resGroup, name, make(chan struct{}))
// }
// resGroup := id.ResourceGroup return err
// name := id.Path["routeTables"] }
//
// _, err = routeTablesClient.Delete(resGroup, name) func expandAzureRmRouteTableRoutes(d *schema.ResourceData) ([]network.Route, error) {
// configs := d.Get("route").(*schema.Set).List()
// return err routes := make([]network.Route, 0, len(configs))
//}
// for _, configRaw := range configs {
//func expandAzureRmRouteTableRoutes(d *schema.ResourceData) ([]network.Route, error) { data := configRaw.(map[string]interface{})
// configs := d.Get("route").(*schema.Set).List()
// routes := make([]network.Route, 0, len(configs)) address_prefix := data["address_prefix"].(string)
// next_hop_type := data["next_hop_type"].(string)
// for _, configRaw := range configs {
// data := configRaw.(map[string]interface{}) properties := network.RoutePropertiesFormat{
// AddressPrefix: &address_prefix,
// address_prefix := data["address_prefix"].(string) NextHopType: network.RouteNextHopType(next_hop_type),
// next_hop_type := data["next_hop_type"].(string) }
//
// properties := network.RoutePropertiesFormat{ if v := data["next_hop_in_ip_address"].(string); v != "" {
// AddressPrefix: &address_prefix, properties.NextHopIPAddress = &v
// NextHopType: network.RouteNextHopType(next_hop_type), }
// }
// name := data["name"].(string)
// if v := data["next_hop_in_ip_address"].(string); v != "" { route := network.Route{
// properties.NextHopIPAddress = &v Name: &name,
// } Properties: &properties,
// }
// name := data["name"].(string)
// route := network.Route{ routes = append(routes, route)
// Name: &name, }
// Properties: &properties,
// } return routes, nil
// }
// routes = append(routes, route)
// } func resourceArmRouteTableRouteHash(v interface{}) int {
// var buf bytes.Buffer
// return routes, nil m := v.(map[string]interface{})
//} buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
// buf.WriteString(fmt.Sprintf("%s-", m["address_prefix"].(string)))
//func routeTableStateRefreshFunc(client *ArmClient, resourceGroupName string, routeTableName string) resource.StateRefreshFunc { buf.WriteString(fmt.Sprintf("%s-", m["next_hop_type"].(string)))
// return func() (interface{}, string, error) {
// res, err := client.routeTablesClient.Get(resourceGroupName, routeTableName, "") return hashcode.String(buf.String())
// if err != nil { }
// return nil, "", fmt.Errorf("Error issuing read request in routeTableStateRefreshFunc to Azure ARM for route table '%s' (RG: '%s'): %s", routeTableName, resourceGroupName, err)
// } func validateRouteTableNextHopType(v interface{}, k string) (ws []string, errors []error) {
// value := strings.ToLower(v.(string))
// return res, *res.Properties.ProvisioningState, nil hopTypes := map[string]bool{
// } "virtualnetworkgateway": true,
//} "vnetlocal": true,
// "internet": true,
//func resourceArmRouteTableRouteHash(v interface{}) int { "virtualappliance": true,
// var buf bytes.Buffer "none": true,
// m := v.(map[string]interface{}) }
// buf.WriteString(fmt.Sprintf("%s-", m["name"].(string)))
// buf.WriteString(fmt.Sprintf("%s-", m["address_prefix"].(string))) if !hopTypes[value] {
// buf.WriteString(fmt.Sprintf("%s-", m["next_hop_type"].(string))) errors = append(errors, fmt.Errorf("Route Table NextHopType Protocol can only be VirtualNetworkGateway, VnetLocal, Internet or VirtualAppliance"))
// }
// return hashcode.String(buf.String()) return
//} }
//
//func validateRouteTableNextHopType(v interface{}, k string) (ws []string, errors []error) {
// value := strings.ToLower(v.(string))
// hopTypes := map[string]bool{
// "virtualnetworkgateway": true,
// "vnetlocal": true,
// "internet": true,
// "virtualappliance": true,
// "none": true,
// }
//
// if !hopTypes[value] {
// errors = append(errors, fmt.Errorf("Route Table NextHopType Protocol can only be VirtualNetworkGateway, VnetLocal, Internet or VirtualAppliance"))
// }
// return
//}

View File

@ -1,294 +1,294 @@
package azurerm package azurerm
//import ( import (
// "fmt" "fmt"
// "net/http" "net/http"
// "testing" "testing"
//
// "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/acctest"
// "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
// "github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
//) )
//
//func TestResourceAzureRMRouteTableNextHopType_validation(t *testing.T) { func TestResourceAzureRMRouteTableNextHopType_validation(t *testing.T) {
// cases := []struct { cases := []struct {
// Value string Value string
// ErrCount int ErrCount int
// }{ }{
// { {
// Value: "Random", Value: "Random",
// ErrCount: 1, ErrCount: 1,
// }, },
// { {
// Value: "VirtualNetworkGateway", Value: "VirtualNetworkGateway",
// ErrCount: 0, ErrCount: 0,
// }, },
// { {
// Value: "VNETLocal", Value: "VNETLocal",
// ErrCount: 0, ErrCount: 0,
// }, },
// { {
// Value: "Internet", Value: "Internet",
// ErrCount: 0, ErrCount: 0,
// }, },
// { {
// Value: "VirtualAppliance", Value: "VirtualAppliance",
// ErrCount: 0, ErrCount: 0,
// }, },
// { {
// Value: "None", Value: "None",
// ErrCount: 0, ErrCount: 0,
// }, },
// { {
// Value: "VIRTUALNETWORKGATEWAY", Value: "VIRTUALNETWORKGATEWAY",
// ErrCount: 0, ErrCount: 0,
// }, },
// { {
// Value: "virtualnetworkgateway", Value: "virtualnetworkgateway",
// ErrCount: 0, ErrCount: 0,
// }, },
// } }
//
// for _, tc := range cases { for _, tc := range cases {
// _, errors := validateRouteTableNextHopType(tc.Value, "azurerm_route_table") _, errors := validateRouteTableNextHopType(tc.Value, "azurerm_route_table")
//
// if len(errors) != tc.ErrCount { if len(errors) != tc.ErrCount {
// t.Fatalf("Expected the Azure RM Route Table nextHopType to trigger a validation error") t.Fatalf("Expected the Azure RM Route Table nextHopType to trigger a validation error")
// } }
// } }
//} }
//
//func TestAccAzureRMRouteTable_basic(t *testing.T) { func TestAccAzureRMRouteTable_basic(t *testing.T) {
//
// ri := acctest.RandInt() ri := acctest.RandInt()
// config := fmt.Sprintf(testAccAzureRMRouteTable_basic, ri, ri) config := fmt.Sprintf(testAccAzureRMRouteTable_basic, ri, ri)
//
// resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
// PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
// Providers: testAccProviders, Providers: testAccProviders,
// CheckDestroy: testCheckAzureRMRouteTableDestroy, CheckDestroy: testCheckAzureRMRouteTableDestroy,
// Steps: []resource.TestStep{ Steps: []resource.TestStep{
// resource.TestStep{ resource.TestStep{
// Config: config, Config: config,
// Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
// testCheckAzureRMRouteTableExists("azurerm_route_table.test"), testCheckAzureRMRouteTableExists("azurerm_route_table.test"),
// ), ),
// }, },
// }, },
// }) })
//} }
//
//func TestAccAzureRMRouteTable_withTags(t *testing.T) { func TestAccAzureRMRouteTable_withTags(t *testing.T) {
//
// ri := acctest.RandInt() ri := acctest.RandInt()
// preConfig := fmt.Sprintf(testAccAzureRMRouteTable_withTags, ri, ri) preConfig := fmt.Sprintf(testAccAzureRMRouteTable_withTags, ri, ri)
// postConfig := fmt.Sprintf(testAccAzureRMRouteTable_withTagsUpdate, ri, ri) postConfig := fmt.Sprintf(testAccAzureRMRouteTable_withTagsUpdate, ri, ri)
//
// resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
// PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
// Providers: testAccProviders, Providers: testAccProviders,
// CheckDestroy: testCheckAzureRMRouteTableDestroy, CheckDestroy: testCheckAzureRMRouteTableDestroy,
// Steps: []resource.TestStep{ Steps: []resource.TestStep{
// resource.TestStep{ resource.TestStep{
// Config: preConfig, Config: preConfig,
// Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
// testCheckAzureRMRouteTableExists("azurerm_route_table.test"), testCheckAzureRMRouteTableExists("azurerm_route_table.test"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "azurerm_route_table.test", "tags.#", "2"), "azurerm_route_table.test", "tags.#", "2"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "azurerm_route_table.test", "tags.environment", "Production"), "azurerm_route_table.test", "tags.environment", "Production"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "azurerm_route_table.test", "tags.cost_center", "MSFT"), "azurerm_route_table.test", "tags.cost_center", "MSFT"),
// ), ),
// }, },
//
// resource.TestStep{ resource.TestStep{
// Config: postConfig, Config: postConfig,
// Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
// testCheckAzureRMRouteTableExists("azurerm_route_table.test"), testCheckAzureRMRouteTableExists("azurerm_route_table.test"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "azurerm_route_table.test", "tags.#", "1"), "azurerm_route_table.test", "tags.#", "1"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "azurerm_route_table.test", "tags.environment", "staging"), "azurerm_route_table.test", "tags.environment", "staging"),
// ), ),
// }, },
// }, },
// }) })
//} }
//
//func TestAccAzureRMRouteTable_multipleRoutes(t *testing.T) { func TestAccAzureRMRouteTable_multipleRoutes(t *testing.T) {
//
// ri := acctest.RandInt() ri := acctest.RandInt()
// preConfig := fmt.Sprintf(testAccAzureRMRouteTable_basic, ri, ri) preConfig := fmt.Sprintf(testAccAzureRMRouteTable_basic, ri, ri)
// postConfig := fmt.Sprintf(testAccAzureRMRouteTable_multipleRoutes, ri, ri) postConfig := fmt.Sprintf(testAccAzureRMRouteTable_multipleRoutes, ri, ri)
//
// resource.Test(t, resource.TestCase{ resource.Test(t, resource.TestCase{
// PreCheck: func() { testAccPreCheck(t) }, PreCheck: func() { testAccPreCheck(t) },
// Providers: testAccProviders, Providers: testAccProviders,
// CheckDestroy: testCheckAzureRMRouteTableDestroy, CheckDestroy: testCheckAzureRMRouteTableDestroy,
// Steps: []resource.TestStep{ Steps: []resource.TestStep{
// resource.TestStep{ resource.TestStep{
// Config: preConfig, Config: preConfig,
// Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
// testCheckAzureRMRouteTableExists("azurerm_route_table.test"), testCheckAzureRMRouteTableExists("azurerm_route_table.test"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "azurerm_route_table.test", "route.#", "1"), "azurerm_route_table.test", "route.#", "1"),
// ), ),
// }, },
//
// resource.TestStep{ resource.TestStep{
// Config: postConfig, Config: postConfig,
// Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
// testCheckAzureRMRouteTableExists("azurerm_route_table.test"), testCheckAzureRMRouteTableExists("azurerm_route_table.test"),
// resource.TestCheckResourceAttr( resource.TestCheckResourceAttr(
// "azurerm_route_table.test", "route.#", "2"), "azurerm_route_table.test", "route.#", "2"),
// ), ),
// }, },
// }, },
// }) })
//} }
//
//func testCheckAzureRMRouteTableExists(name string) resource.TestCheckFunc { func testCheckAzureRMRouteTableExists(name string) resource.TestCheckFunc {
// return func(s *terraform.State) error { return func(s *terraform.State) error {
//
// rs, ok := s.RootModule().Resources[name] rs, ok := s.RootModule().Resources[name]
// if !ok { if !ok {
// return fmt.Errorf("Not found: %s", name) return fmt.Errorf("Not found: %s", name)
// } }
//
// name := rs.Primary.Attributes["name"] name := rs.Primary.Attributes["name"]
// resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
// if !hasResourceGroup { if !hasResourceGroup {
// return fmt.Errorf("Bad: no resource group found in state for route table: %s", name) return fmt.Errorf("Bad: no resource group found in state for route table: %s", name)
// } }
//
// conn := testAccProvider.Meta().(*ArmClient).routeTablesClient conn := testAccProvider.Meta().(*ArmClient).routeTablesClient
//
// resp, err := conn.Get(resourceGroup, name, "") resp, err := conn.Get(resourceGroup, name, "")
// if err != nil { if err != nil {
// return fmt.Errorf("Bad: Get on routeTablesClient: %s", err) return fmt.Errorf("Bad: Get on routeTablesClient: %s", err)
// } }
//
// if resp.StatusCode == http.StatusNotFound { if resp.StatusCode == http.StatusNotFound {
// return fmt.Errorf("Bad: Route Table %q (resource group: %q) does not exist", name, resourceGroup) return fmt.Errorf("Bad: Route Table %q (resource group: %q) does not exist", name, resourceGroup)
// } }
//
// return nil return nil
// } }
//} }
//
//func testCheckAzureRMRouteTableDestroy(s *terraform.State) error { func testCheckAzureRMRouteTableDestroy(s *terraform.State) error {
// conn := testAccProvider.Meta().(*ArmClient).routeTablesClient conn := testAccProvider.Meta().(*ArmClient).routeTablesClient
//
// for _, rs := range s.RootModule().Resources { for _, rs := range s.RootModule().Resources {
// if rs.Type != "azurerm_route_table" { if rs.Type != "azurerm_route_table" {
// continue continue
// } }
//
// name := rs.Primary.Attributes["name"] name := rs.Primary.Attributes["name"]
// resourceGroup := rs.Primary.Attributes["resource_group_name"] resourceGroup := rs.Primary.Attributes["resource_group_name"]
//
// resp, err := conn.Get(resourceGroup, name, "") resp, err := conn.Get(resourceGroup, name, "")
//
// if err != nil { if err != nil {
// return nil return nil
// } }
//
// if resp.StatusCode != http.StatusNotFound { if resp.StatusCode != http.StatusNotFound {
// return fmt.Errorf("Route Table still exists:\n%#v", resp.Properties) return fmt.Errorf("Route Table still exists:\n%#v", resp.Properties)
// } }
// } }
//
// return nil return nil
//} }
//
//var testAccAzureRMRouteTable_basic = ` var testAccAzureRMRouteTable_basic = `
//resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
// name = "acctestrg-%d" name = "acctestrg-%d"
// location = "West US" location = "West US"
//} }
//
//resource "azurerm_route_table" "test" { resource "azurerm_route_table" "test" {
// name = "acctestrt%d" name = "acctestrt%d"
// location = "West US" location = "West US"
// resource_group_name = "${azurerm_resource_group.test.name}" resource_group_name = "${azurerm_resource_group.test.name}"
//
// route { route {
// name = "route1" name = "route1"
// address_prefix = "*" address_prefix = "*"
// next_hop_type = "internet" next_hop_type = "internet"
// } }
//} }
//` `
//
//var testAccAzureRMRouteTable_multipleRoutes = ` var testAccAzureRMRouteTable_multipleRoutes = `
//resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
// name = "acctestrg-%d" name = "acctestrg-%d"
// location = "West US" location = "West US"
//} }
//
//resource "azurerm_route_table" "test" { resource "azurerm_route_table" "test" {
// name = "acctestrt%d" name = "acctestrt%d"
// location = "West US" location = "West US"
// resource_group_name = "${azurerm_resource_group.test.name}" resource_group_name = "${azurerm_resource_group.test.name}"
//
// route { route {
// name = "route1" name = "route1"
// address_prefix = "*" address_prefix = "*"
// next_hop_type = "internet" next_hop_type = "internet"
// } }
//
// route { route {
// name = "route2" name = "route2"
// address_prefix = "*" address_prefix = "*"
// next_hop_type = "virtualappliance" next_hop_type = "virtualappliance"
// } }
//} }
//` `
//
//var testAccAzureRMRouteTable_withTags = ` var testAccAzureRMRouteTable_withTags = `
//resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
// name = "acctestrg-%d" name = "acctestrg-%d"
// location = "West US" location = "West US"
//} }
//
//resource "azurerm_route_table" "test" { resource "azurerm_route_table" "test" {
// name = "acctestrt%d" name = "acctestrt%d"
// location = "West US" location = "West US"
// resource_group_name = "${azurerm_resource_group.test.name}" resource_group_name = "${azurerm_resource_group.test.name}"
//
// route { route {
// name = "route1" name = "route1"
// address_prefix = "*" address_prefix = "*"
// next_hop_type = "internet" next_hop_type = "internet"
// } }
//
// tags { tags {
// environment = "Production" environment = "Production"
// cost_center = "MSFT" cost_center = "MSFT"
// } }
//} }
//` `
//
//var testAccAzureRMRouteTable_withTagsUpdate = ` var testAccAzureRMRouteTable_withTagsUpdate = `
//resource "azurerm_resource_group" "test" { resource "azurerm_resource_group" "test" {
// name = "acctestrg-%d" name = "acctestrg-%d"
// location = "West US" location = "West US"
//} }
//
//resource "azurerm_route_table" "test" { resource "azurerm_route_table" "test" {
// name = "acctestrt%d" name = "acctestrt%d"
// location = "West US" location = "West US"
// resource_group_name = "${azurerm_resource_group.test.name}" resource_group_name = "${azurerm_resource_group.test.name}"
//
// route { route {
// name = "route1" name = "route1"
// address_prefix = "*" address_prefix = "*"
// next_hop_type = "internet" next_hop_type = "internet"
// } }
//
// tags { tags {
// environment = "staging" environment = "staging"
// } }
//} }
//` `