From 948a95d67d7db708813f98a110742f308912ea46 Mon Sep 17 00:00:00 2001 From: David Symonds Date: Sun, 22 Oct 2023 12:45:55 +1100 Subject: [PATCH] Support importing tailscale_dns_preferences resources. Also document importing tailscale_acl resources, which was supported from #186. --- docs/resources/acl.md | 9 +++++++++ docs/resources/dns_preferences.md | 9 +++++++++ examples/resources/tailscale_acl/import.sh | 1 + examples/resources/tailscale_dns_preferences/import.sh | 1 + tailscale/resource_dns_preferences.go | 3 +++ 5 files changed, 23 insertions(+) create mode 100644 examples/resources/tailscale_acl/import.sh create mode 100644 examples/resources/tailscale_dns_preferences/import.sh diff --git a/docs/resources/acl.md b/docs/resources/acl.md index 8f3bf273..21750aa7 100644 --- a/docs/resources/acl.md +++ b/docs/resources/acl.md @@ -36,3 +36,12 @@ resource "tailscale_acl" "sample_acl" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +Import is supported using the following syntax: + +```shell +# ID doesn't matter. +terraform import tailscale_acl.sample_acl acl +``` diff --git a/docs/resources/dns_preferences.md b/docs/resources/dns_preferences.md index ae898e4f..a29821cd 100644 --- a/docs/resources/dns_preferences.md +++ b/docs/resources/dns_preferences.md @@ -28,3 +28,12 @@ resource "tailscale_dns_preferences" "sample_preferences" { ### Read-Only - `id` (String) The ID of this resource. + +## Import + +Import is supported using the following syntax: + +```shell +# ID doesn't matter. +terraform import tailscale_dns_preferences.sample_preferences dns_preferences +``` diff --git a/examples/resources/tailscale_acl/import.sh b/examples/resources/tailscale_acl/import.sh new file mode 100644 index 00000000..a9f05165 --- /dev/null +++ b/examples/resources/tailscale_acl/import.sh @@ -0,0 +1 @@ +terraform import tailscale_acl.sample_acl acl diff --git a/examples/resources/tailscale_dns_preferences/import.sh b/examples/resources/tailscale_dns_preferences/import.sh new file mode 100644 index 00000000..e6984d02 --- /dev/null +++ b/examples/resources/tailscale_dns_preferences/import.sh @@ -0,0 +1 @@ +terraform import tailscale_dns_preferences.sample_preferences dns_preferences diff --git a/tailscale/resource_dns_preferences.go b/tailscale/resource_dns_preferences.go index ed1918f2..23a65271 100644 --- a/tailscale/resource_dns_preferences.go +++ b/tailscale/resource_dns_preferences.go @@ -16,6 +16,9 @@ func resourceDNSPreferences() *schema.Resource { CreateContext: resourceDNSPreferencesCreate, UpdateContext: resourceDNSPreferencesUpdate, DeleteContext: resourceDNSPreferencesDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, Schema: map[string]*schema.Schema{ "magic_dns": { Type: schema.TypeBool,