provider/azurerm: enable import of more resources (#10195)

* provider/azurerm: support import of virtual_machine

TF_ACC=1 go test ./builtin/providers/azurerm -v -run "TestAccAzureRMVirtualMachine_(basic|import)" -timeout 120m
=== RUN   TestAccAzureRMVirtualMachine_importBasic
--- PASS: TestAccAzureRMVirtualMachine_importBasic (561.08s)
=== RUN   TestAccAzureRMVirtualMachine_basicLinuxMachine
--- PASS: TestAccAzureRMVirtualMachine_basicLinuxMachine (677.49s)
=== RUN   TestAccAzureRMVirtualMachine_basicLinuxMachine_disappears
--- PASS: TestAccAzureRMVirtualMachine_basicLinuxMachine_disappears (674.21s)
=== RUN   TestAccAzureRMVirtualMachine_basicWindowsMachine
--- PASS: TestAccAzureRMVirtualMachine_basicWindowsMachine (1105.18s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	3017.970s

* provider/azurerm: support import of servicebus_namespace

TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMServiceBusNamespace_import -timeout 120m
=== RUN   TestAccAzureRMServiceBusNamespace_importBasic
--- PASS: TestAccAzureRMServiceBusNamespace_importBasic (345.80s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	345.879s

* provider/azurerm: document import of servicebus_topic and servicebus_subscription

* provider/azurerm: support import of dns record resources

TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMDns[A-z]+Record_importBasic -timeout 120m
=== RUN   TestAccAzureRMDnsARecord_importBasic
--- PASS: TestAccAzureRMDnsARecord_importBasic (102.84s)
=== RUN   TestAccAzureRMDnsAAAARecord_importBasic
--- PASS: TestAccAzureRMDnsAAAARecord_importBasic (100.59s)
=== RUN   TestAccAzureRMDnsCNameRecord_importBasic
--- PASS: TestAccAzureRMDnsCNameRecord_importBasic (98.94s)
=== RUN   TestAccAzureRMDnsMxRecord_importBasic
--- PASS: TestAccAzureRMDnsMxRecord_importBasic (107.30s)
=== RUN   TestAccAzureRMDnsNsRecord_importBasic
--- PASS: TestAccAzureRMDnsNsRecord_importBasic (98.55s)
=== RUN   TestAccAzureRMDnsSrvRecord_importBasic
--- PASS: TestAccAzureRMDnsSrvRecord_importBasic (100.19s)
=== RUN   TestAccAzureRMDnsTxtRecord_importBasic
--- PASS: TestAccAzureRMDnsTxtRecord_importBasic (97.49s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	706.000s

* provider/azurerm: support import of cdn_endpoint, document profile import

TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMCdnEndpoint_import -timeout 120m
=== RUN   TestAccAzureRMCdnEndpoint_importWithTags
--- PASS: TestAccAzureRMCdnEndpoint_importWithTags (207.83s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	207.907s

* provider/azurerm: support import of sql_server, fix sql_firewall import

TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMSql[A-z]+_importBasic -timeout 120m
=== RUN   TestAccAzureRMSqlFirewallRule_importBasic
--- PASS: TestAccAzureRMSqlFirewallRule_importBasic (153.72s)
=== RUN   TestAccAzureRMSqlServer_importBasic
--- PASS: TestAccAzureRMSqlServer_importBasic (119.83s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	273.630s
This commit is contained in:
Peter McAtominey 2016-11-22 12:13:11 +00:00 committed by Paul Stack
parent 60780e34b5
commit e3e8261857
39 changed files with 599 additions and 8 deletions

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMCdnEndpoint_importWithTags(t *testing.T) {
resourceName := "azurerm_cdn_endpoint.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMCdnEndpoint_withTags, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMCdnEndpointDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMDnsARecord_importBasic(t *testing.T) {
resourceName := "azurerm_dns_a_record.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsARecord_basic, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsARecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMDnsAAAARecord_importBasic(t *testing.T) {
resourceName := "azurerm_dns_aaaa_record.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsAAAARecord_basic, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsAAAARecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMDnsCNameRecord_importBasic(t *testing.T) {
resourceName := "azurerm_dns_cname_record.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsCNameRecord_basic, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsCNameRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMDnsMxRecord_importBasic(t *testing.T) {
resourceName := "azurerm_dns_mx_record.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsMxRecord_basic, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsMxRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMDnsNsRecord_importBasic(t *testing.T) {
resourceName := "azurerm_dns_ns_record.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsNsRecord_basic, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsNsRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMDnsSrvRecord_importBasic(t *testing.T) {
resourceName := "azurerm_dns_srv_record.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsSrvRecord_basic, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsSrvRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMDnsTxtRecord_importBasic(t *testing.T) {
resourceName := "azurerm_dns_txt_record.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsTxtRecord_basic, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsTxtRecordDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -0,0 +1,33 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMServiceBusNamespace_importBasic(t *testing.T) {
resourceName := "azurerm_servicebus_namespace.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMServiceBusNamespace_basic, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMServiceBusNamespaceDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -27,7 +27,6 @@ func TestAccAzureRMSqlFirewallRule_importBasic(t *testing.T) {
ResourceName: resourceName, ResourceName: resourceName,
ImportState: true, ImportState: true,
ImportStateVerify: true, ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"server_name"},
}, },
}, },
}) })

View File

@ -0,0 +1,34 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMSqlServer_importBasic(t *testing.T) {
resourceName := "azurerm_sql_server.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMSqlServer_basic, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMSqlServerDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"administrator_login_password"},
},
},
})
}

View File

@ -0,0 +1,37 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMVirtualMachine_importBasic(t *testing.T) {
resourceName := "azurerm_virtual_machine.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMVirtualMachine_basicLinuxMachine, ri, ri, ri, ri, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualMachineDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"delete_data_disks_on_termination",
"delete_os_disk_on_termination",
},
},
},
})
}

View File

@ -18,6 +18,9 @@ func resourceArmCdnEndpoint() *schema.Resource {
Read: resourceArmCdnEndpointRead, Read: resourceArmCdnEndpointRead,
Update: resourceArmCdnEndpointUpdate, Update: resourceArmCdnEndpointUpdate,
Delete: resourceArmCdnEndpointDelete, Delete: resourceArmCdnEndpointDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": { "name": {
@ -234,6 +237,9 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error
} }
d.Set("name", resp.Name) d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("profile_name", profileName)
d.Set("host_name", resp.Properties.HostName) d.Set("host_name", resp.Properties.HostName)
d.Set("is_compression_enabled", resp.Properties.IsCompressionEnabled) d.Set("is_compression_enabled", resp.Properties.IsCompressionEnabled)
d.Set("is_http_allowed", resp.Properties.IsHTTPAllowed) d.Set("is_http_allowed", resp.Properties.IsHTTPAllowed)
@ -245,7 +251,7 @@ func resourceArmCdnEndpointRead(d *schema.ResourceData, meta interface{}) error
if resp.Properties.OriginPath != nil && *resp.Properties.OriginPath != "" { if resp.Properties.OriginPath != nil && *resp.Properties.OriginPath != "" {
d.Set("origin_path", resp.Properties.OriginPath) d.Set("origin_path", resp.Properties.OriginPath)
} }
if resp.Properties.ContentTypesToCompress != nil && len(*resp.Properties.ContentTypesToCompress) > 0 { if resp.Properties.ContentTypesToCompress != nil {
d.Set("content_types_to_compress", flattenAzureRMCdnEndpointContentTypes(resp.Properties.ContentTypesToCompress)) d.Set("content_types_to_compress", flattenAzureRMCdnEndpointContentTypes(resp.Properties.ContentTypesToCompress))
} }
d.Set("origin", flattenAzureRMCdnEndpointOrigin(resp.Properties.Origins)) d.Set("origin", flattenAzureRMCdnEndpointOrigin(resp.Properties.Origins))

View File

@ -14,6 +14,9 @@ func resourceArmDnsARecord() *schema.Resource {
Read: resourceArmDnsARecordRead, Read: resourceArmDnsARecordRead,
Update: resourceArmDnsARecordCreate, Update: resourceArmDnsARecordCreate,
Delete: resourceArmDnsARecordDelete, Delete: resourceArmDnsARecordDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -111,6 +114,11 @@ func resourceArmDnsARecordRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &dns.GetARecordSet{} readRequest.Command = &dns.GetARecordSet{}
@ -126,6 +134,9 @@ func resourceArmDnsARecordRead(d *schema.ResourceData, meta interface{}) error {
resp := readResponse.Parsed.(*dns.GetARecordSetResponse) resp := readResponse.Parsed.(*dns.GetARecordSetResponse)
d.Set("name", resp.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("zone_name", id.Path["dnszones"])
d.Set("ttl", resp.TTL) d.Set("ttl", resp.TTL)
if resp.ARecords != nil { if resp.ARecords != nil {

View File

@ -14,6 +14,9 @@ func resourceArmDnsAAAARecord() *schema.Resource {
Read: resourceArmDnsAAAARecordRead, Read: resourceArmDnsAAAARecordRead,
Update: resourceArmDnsAAAARecordCreate, Update: resourceArmDnsAAAARecordCreate,
Delete: resourceArmDnsAAAARecordDelete, Delete: resourceArmDnsAAAARecordDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -111,6 +114,11 @@ func resourceArmDnsAAAARecordRead(d *schema.ResourceData, meta interface{}) erro
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &dns.GetAAAARecordSet{} readRequest.Command = &dns.GetAAAARecordSet{}
@ -126,6 +134,9 @@ func resourceArmDnsAAAARecordRead(d *schema.ResourceData, meta interface{}) erro
resp := readResponse.Parsed.(*dns.GetAAAARecordSetResponse) resp := readResponse.Parsed.(*dns.GetAAAARecordSetResponse)
d.Set("name", resp.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("zone_name", id.Path["dnszones"])
d.Set("ttl", resp.TTL) d.Set("ttl", resp.TTL)
if resp.AAAARecords != nil { if resp.AAAARecords != nil {

View File

@ -14,6 +14,9 @@ func resourceArmDnsCNameRecord() *schema.Resource {
Read: resourceArmDnsCNameRecordRead, Read: resourceArmDnsCNameRecordRead,
Update: resourceArmDnsCNameRecordCreate, Update: resourceArmDnsCNameRecordCreate,
Delete: resourceArmDnsCNameRecordDelete, Delete: resourceArmDnsCNameRecordDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -111,6 +114,11 @@ func resourceArmDnsCNameRecordRead(d *schema.ResourceData, meta interface{}) err
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &dns.GetCNAMERecordSet{} readRequest.Command = &dns.GetCNAMERecordSet{}
@ -126,6 +134,9 @@ func resourceArmDnsCNameRecordRead(d *schema.ResourceData, meta interface{}) err
resp := readResponse.Parsed.(*dns.GetCNAMERecordSetResponse) resp := readResponse.Parsed.(*dns.GetCNAMERecordSetResponse)
d.Set("name", resp.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("zone_name", id.Path["dnszones"])
d.Set("ttl", resp.TTL) d.Set("ttl", resp.TTL)
d.Set("record", resp.CNAMERecord.CNAME) d.Set("record", resp.CNAMERecord.CNAME)

View File

@ -16,6 +16,9 @@ func resourceArmDnsMxRecord() *schema.Resource {
Read: resourceArmDnsMxRecordRead, Read: resourceArmDnsMxRecordRead,
Update: resourceArmDnsMxRecordCreate, Update: resourceArmDnsMxRecordCreate,
Delete: resourceArmDnsMxRecordDelete, Delete: resourceArmDnsMxRecordDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -122,6 +125,11 @@ func resourceArmDnsMxRecordRead(d *schema.ResourceData, meta interface{}) error
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &dns.GetMXRecordSet{} readRequest.Command = &dns.GetMXRecordSet{}
@ -137,6 +145,9 @@ func resourceArmDnsMxRecordRead(d *schema.ResourceData, meta interface{}) error
resp := readResponse.Parsed.(*dns.GetMXRecordSetResponse) resp := readResponse.Parsed.(*dns.GetMXRecordSetResponse)
d.Set("name", resp.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("zone_name", id.Path["dnszones"])
d.Set("ttl", resp.TTL) d.Set("ttl", resp.TTL)
if err := d.Set("record", flattenAzureRmDnsMxRecord(resp.MXRecords)); err != nil { if err := d.Set("record", flattenAzureRmDnsMxRecord(resp.MXRecords)); err != nil {

View File

@ -14,6 +14,9 @@ func resourceArmDnsNsRecord() *schema.Resource {
Read: resourceArmDnsNsRecordRead, Read: resourceArmDnsNsRecordRead,
Update: resourceArmDnsNsRecordCreate, Update: resourceArmDnsNsRecordCreate,
Delete: resourceArmDnsNsRecordDelete, Delete: resourceArmDnsNsRecordDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -114,6 +117,11 @@ func resourceArmDnsNsRecordRead(d *schema.ResourceData, meta interface{}) error
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &dns.GetNSRecordSet{} readRequest.Command = &dns.GetNSRecordSet{}
@ -129,6 +137,9 @@ func resourceArmDnsNsRecordRead(d *schema.ResourceData, meta interface{}) error
resp := readResponse.Parsed.(*dns.GetNSRecordSetResponse) resp := readResponse.Parsed.(*dns.GetNSRecordSetResponse)
d.Set("name", resp.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("zone_name", id.Path["dnszones"])
d.Set("ttl", resp.TTL) d.Set("ttl", resp.TTL)
if resp.NSRecords != nil { if resp.NSRecords != nil {

View File

@ -16,6 +16,9 @@ func resourceArmDnsSrvRecord() *schema.Resource {
Read: resourceArmDnsSrvRecordRead, Read: resourceArmDnsSrvRecordRead,
Update: resourceArmDnsSrvRecordCreate, Update: resourceArmDnsSrvRecordCreate,
Delete: resourceArmDnsSrvRecordDelete, Delete: resourceArmDnsSrvRecordDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -132,6 +135,11 @@ func resourceArmDnsSrvRecordRead(d *schema.ResourceData, meta interface{}) error
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &dns.GetSRVRecordSet{} readRequest.Command = &dns.GetSRVRecordSet{}
@ -147,6 +155,9 @@ func resourceArmDnsSrvRecordRead(d *schema.ResourceData, meta interface{}) error
resp := readResponse.Parsed.(*dns.GetSRVRecordSetResponse) resp := readResponse.Parsed.(*dns.GetSRVRecordSetResponse)
d.Set("name", resp.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("zone_name", id.Path["dnszones"])
d.Set("ttl", resp.TTL) d.Set("ttl", resp.TTL)
if err := d.Set("record", flattenAzureRmDnsSrvRecord(resp.SRVRecords)); err != nil { if err := d.Set("record", flattenAzureRmDnsSrvRecord(resp.SRVRecords)); err != nil {

View File

@ -14,6 +14,9 @@ func resourceArmDnsTxtRecord() *schema.Resource {
Read: resourceArmDnsTxtRecordRead, Read: resourceArmDnsTxtRecordRead,
Update: resourceArmDnsTxtRecordCreate, Update: resourceArmDnsTxtRecordCreate,
Delete: resourceArmDnsTxtRecordDelete, Delete: resourceArmDnsTxtRecordDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -114,6 +117,11 @@ func resourceArmDnsTxtRecordRead(d *schema.ResourceData, meta interface{}) error
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &dns.GetTXTRecordSet{} readRequest.Command = &dns.GetTXTRecordSet{}
@ -129,6 +137,9 @@ func resourceArmDnsTxtRecordRead(d *schema.ResourceData, meta interface{}) error
resp := readResponse.Parsed.(*dns.GetTXTRecordSetResponse) resp := readResponse.Parsed.(*dns.GetTXTRecordSetResponse)
d.Set("name", resp.Name)
d.Set("resource_group_name", id.ResourceGroup)
d.Set("zone_name", id.Path["dnszones"])
d.Set("ttl", resp.TTL) d.Set("ttl", resp.TTL)
if resp.TXTRecords != nil { if resp.TXTRecords != nil {

View File

@ -145,6 +145,8 @@ func resourceArmServiceBusNamespaceRead(d *schema.ResourceData, meta interface{}
} }
d.Set("name", resp.Name) d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("sku", strings.ToLower(string(resp.Sku.Name))) d.Set("sku", strings.ToLower(string(resp.Sku.Name)))
d.Set("capacity", resp.Sku.Capacity) d.Set("capacity", resp.Sku.Capacity)

View File

@ -119,7 +119,9 @@ func resourceArmSqlFirewallRuleRead(d *schema.ResourceData, meta interface{}) er
resp := readResponse.Parsed.(*sql.GetFirewallRuleResponse) resp := readResponse.Parsed.(*sql.GetFirewallRuleResponse)
d.Set("resource_group_name", resGroup) d.Set("resource_group_name", resGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("name", resp.Name) d.Set("name", resp.Name)
d.Set("server_name", id.Path["servers"])
d.Set("start_ip_address", resp.StartIPAddress) d.Set("start_ip_address", resp.StartIPAddress)
d.Set("end_ip_address", resp.EndIPAddress) d.Set("end_ip_address", resp.EndIPAddress)

View File

@ -15,6 +15,9 @@ func resourceArmSqlServer() *schema.Resource {
Read: resourceArmSqlServerRead, Read: resourceArmSqlServerRead,
Update: resourceArmSqlServerCreate, Update: resourceArmSqlServerCreate,
Delete: resourceArmSqlServerDelete, Delete: resourceArmSqlServerDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": &schema.Schema{ "name": &schema.Schema{
@ -111,6 +114,11 @@ func resourceArmSqlServerRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient) client := meta.(*ArmClient)
rivieraClient := client.rivieraClient rivieraClient := client.rivieraClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
readRequest := rivieraClient.NewRequestForURI(d.Id()) readRequest := rivieraClient.NewRequestForURI(d.Id())
readRequest.Command = &sql.GetServer{} readRequest.Command = &sql.GetServer{}
@ -126,6 +134,9 @@ func resourceArmSqlServerRead(d *schema.ResourceData, meta interface{}) error {
resp := readResponse.Parsed.(*sql.GetServerResponse) resp := readResponse.Parsed.(*sql.GetServerResponse)
d.Set("name", id.Path["servers"])
d.Set("resource_group_name", id.ResourceGroup)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("fully_qualified_domain_name", resp.FullyQualifiedDomainName) d.Set("fully_qualified_domain_name", resp.FullyQualifiedDomainName)
d.Set("administrator_login", resp.AdministratorLogin) d.Set("administrator_login", resp.AdministratorLogin)
d.Set("version", resp.Version) d.Set("version", resp.Version)

View File

@ -20,6 +20,9 @@ func resourceArmVirtualMachine() *schema.Resource {
Read: resourceArmVirtualMachineRead, Read: resourceArmVirtualMachineRead,
Update: resourceArmVirtualMachineCreate, Update: resourceArmVirtualMachineCreate,
Delete: resourceArmVirtualMachineDelete, Delete: resourceArmVirtualMachineDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": { "name": {
@ -44,7 +47,6 @@ func resourceArmVirtualMachine() *schema.Resource {
"plan": { "plan": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
Computed: true,
MaxItems: 1, MaxItems: 1,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
@ -559,6 +561,10 @@ func resourceArmVirtualMachineRead(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Error making Read request on Azure Virtual Machine %s: %s", name, err) return fmt.Errorf("Error making Read request on Azure Virtual Machine %s: %s", name, err)
} }
d.Set("name", resp.Name)
d.Set("resource_group_name", resGroup)
d.Set("location", resp.Location)
if resp.Plan != nil { if resp.Plan != nil {
if err := d.Set("plan", flattenAzureRmVirtualMachinePlan(resp.Plan)); err != nil { if err := d.Set("plan", flattenAzureRmVirtualMachinePlan(resp.Plan)); err != nil {
return fmt.Errorf("[DEBUG] Error setting Virtual Machine Plan error: %#v", err) return fmt.Errorf("[DEBUG] Error setting Virtual Machine Plan error: %#v", err)

View File

@ -85,3 +85,11 @@ The `origin` block supports:
The following attributes are exported: The following attributes are exported:
* `id` - The CDN Endpoint ID. * `id` - The CDN Endpoint ID.
## Import
CDN Endpoints can be imported using the `resource id`, e.g.
```
terraform import azurerm_cdn_endpoint.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Cdn/profiles/myprofile1/endpoints/myendpoint1
```

View File

@ -52,3 +52,11 @@ The following arguments are supported:
The following attributes are exported: The following attributes are exported:
* `id` - The CDN Profile ID. * `id` - The CDN Profile ID.
## Import
CDN Profiles can be imported using the `resource id`, e.g.
```
terraform import azurerm_cdn_profile.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Cdn/profiles/myprofile1
```

View File

@ -51,3 +51,11 @@ The following arguments are supported:
The following attributes are exported: The following attributes are exported:
* `id` - The DNS A Record ID. * `id` - The DNS A Record ID.
## Import
A records can be imported using the `resource id`, e.g.
```
terraform import azurerm_dns_a_record.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/A/myrecord1
```

View File

@ -51,3 +51,11 @@ The following arguments are supported:
The following attributes are exported: The following attributes are exported:
* `id` - The DNS AAAA Record ID. * `id` - The DNS AAAA Record ID.
## Import
AAAA records can be imported using the `resource id`, e.g.
```
terraform import azurerm_dns_aaaa_record.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/AAAA/myrecord1
```

View File

@ -51,3 +51,11 @@ The following arguments are supported:
The following attributes are exported: The following attributes are exported:
* `id` - The DNS CName Record ID. * `id` - The DNS CName Record ID.
## Import
CNAME records can be imported using the `resource id`, e.g.
```
terraform import azurerm_dns_cname_record.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/CNAME/myrecord1
```

View File

@ -70,3 +70,11 @@ The `record` block supports:
The following attributes are exported: The following attributes are exported:
* `id` - The DNS MX Record ID. * `id` - The DNS MX Record ID.
## Import
MX records can be imported using the `resource id`, e.g.
```
terraform import azurerm_dns_mx_record.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/MX/myrecord1
```

View File

@ -65,3 +65,11 @@ The `record` block supports:
The following attributes are exported: The following attributes are exported:
* `id` - The DNS NS Record ID. * `id` - The DNS NS Record ID.
## Import
NS records can be imported using the `resource id`, e.g.
```
terraform import azurerm_dns_ns_record.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/NS/myrecord1
```

View File

@ -72,3 +72,11 @@ The `record` block supports:
The following attributes are exported: The following attributes are exported:
* `id` - The DNS SRV Record ID. * `id` - The DNS SRV Record ID.
## Import
SRV records can be imported using the `resource id`, e.g.
```
terraform import azurerm_dns_srv_record.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/SRV/myrecord1
```

View File

@ -64,3 +64,11 @@ The `record` block supports:
The following attributes are exported: The following attributes are exported:
* `id` - The DNS TXT Record ID. * `id` - The DNS TXT Record ID.
## Import
TXT records can be imported using the `resource id`, e.g.
```
terraform import azurerm_dns_txt_record.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/dnsZones/zone1/TXT/myrecord1
```

View File

@ -101,3 +101,11 @@ The following attributes are exported:
* `virtual_machine_id` - Reference to a VM with which this NIC has been associated. * `virtual_machine_id` - Reference to a VM with which this NIC has been associated.
* `applied_dns_servers` - If the VM that uses this NIC is part of an Availability Set, then this list will have the union of all DNS servers from all NICs that are part of the Availability Set * `applied_dns_servers` - If the VM that uses this NIC is part of an Availability Set, then this list will have the union of all DNS servers from all NICs that are part of the Availability Set
* `internal_fqdn` - Fully qualified DNS name supporting internal communications between VMs in the same VNet * `internal_fqdn` - Fully qualified DNS name supporting internal communications between VMs in the same VNet
## Import
Network Interfaces can be imported using the `resource id`, e.g.
```
terraform import azurerm_network_interface.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.network/networkInterfaces/nic1
```

View File

@ -66,3 +66,11 @@ The following attributes are exported only if there is an authorization rule nam
* `default_primary_key` - The primary access key for the authorization rule `RootManageSharedAccessKey`. * `default_primary_key` - The primary access key for the authorization rule `RootManageSharedAccessKey`.
* `default_secondary_key` - The secondary access key for the authorization rule `RootManageSharedAccessKey`. * `default_secondary_key` - The secondary access key for the authorization rule `RootManageSharedAccessKey`.
## Import
Service Bus Namespace can be imported using the `resource id`, e.g.
```
terraform import azurerm_servicebus_namespace.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.servicebus/namespaces/sbns1
```

View File

@ -105,3 +105,11 @@ used to represent a lengh of time. The supported format is documented [here](htt
The following attributes are exported: The following attributes are exported:
* `id` - The ServiceBus Subscription ID. * `id` - The ServiceBus Subscription ID.
## Import
Service Bus Subscriptions can be imported using the `resource id`, e.g.
```
terraform import azurerm_servicebus_subscription.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.servicebus/namespaces/sbns1/topics/sntopic1/subscriptions/sbsub1
```

View File

@ -106,3 +106,11 @@ used to represent a lengh of time. The supported format is documented [here](htt
The following attributes are exported: The following attributes are exported:
* `id` - The ServiceBus Topic ID. * `id` - The ServiceBus Topic ID.
## Import
Service Bus Topics can be imported using the `resource id`, e.g.
```
terraform import azurerm_servicebus_topic.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.servicebus/namespaces/sbns1/topics/sntopic1
```

View File

@ -55,3 +55,11 @@ The following attributes are exported:
* `id` - The SQL Server ID. * `id` - The SQL Server ID.
* `fully_qualified_domain_name` - The fully qualified domain name of the Azure SQL Server (e.g. myServerName.database.windows.net) * `fully_qualified_domain_name` - The fully qualified domain name of the Azure SQL Server (e.g. myServerName.database.windows.net)
## Import
SQL Servers can be imported using the `resource id`, e.g.
```
terraform import azurerm_sql_server.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/servers/myserver
```

View File

@ -313,3 +313,11 @@ For more information on the different example configurations, please check out t
The following attributes are exported: The following attributes are exported:
* `id` - The virtual machine ID. * `id` - The virtual machine ID.
## Import
Virtual Machines can be imported using the `resource id`, e.g.
```
terraform import azurerm_virtual_machine.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.compute/virtualMachines/machine1
```