diff --git a/docs/data-sources/dns_record.md b/docs/data-sources/dns_record.md index 6c156df..2afcc85 100644 --- a/docs/data-sources/dns_record.md +++ b/docs/data-sources/dns_record.md @@ -3,12 +3,12 @@ page_title: "netbird_dns_record Data Source - netbird" subcategory: "" description: |- - Read DNS Record information. + Read DNS Record metadata, see NetBird Docs https://docs.netbird.io/manage/dns/custom-zones for more information. --- # netbird_dns_record (Data Source) -Read DNS Record information. +Read DNS Record metadata, see [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information. ## Example Usage @@ -16,18 +16,18 @@ Read DNS Record information. # Query by ID data "netbird_dns_record" "by_id" { zone_id = netbird_dns_zone.example.id - id = "record-id-here" + id = "d50moeqtvgfc7398k38g" } # Query by name and type -data "netbird_dns_record" "www" { +data "netbird_dns_record" "by_name_and_type" { zone_id = netbird_dns_zone.example.id name = "www.example.local" type = "A" } # Query by name only -data "netbird_dns_record" "api" { +data "netbird_dns_record" "by_name" { zone_id = netbird_dns_zone.example.id name = "api.example.local" } diff --git a/docs/data-sources/dns_zone.md b/docs/data-sources/dns_zone.md index 72b9c59..9b408df 100644 --- a/docs/data-sources/dns_zone.md +++ b/docs/data-sources/dns_zone.md @@ -3,23 +3,23 @@ page_title: "netbird_dns_zone Data Source - netbird" subcategory: "" description: |- - Read DNS Zone information. + Read DNS Zone metadata, see NetBird Docs https://docs.netbird.io/manage/dns/custom-zones for more information. --- # netbird_dns_zone (Data Source) -Read DNS Zone information. +Read DNS Zone metadata, see [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information. ## Example Usage ```terraform -data "netbird_dns_zone" "example" { - name = "example-zone" +data "netbird_dns_zone" "by_name" { + name = "example.local" } # Query by ID data "netbird_dns_zone" "by_id" { - id = "zone-id-here" + id = "d50ltp59q2cs73ea7ss0" } # Query by domain diff --git a/docs/resources/dns_record.md b/docs/resources/dns_record.md index 95e0dd7..ad7c4b7 100644 --- a/docs/resources/dns_record.md +++ b/docs/resources/dns_record.md @@ -3,12 +3,12 @@ page_title: "netbird_dns_record Resource - netbird" subcategory: "" description: |- - Create and manage DNS records within DNS zones. See NetBird Docs https://docs.netbird.io/how-to/manage-dns-in-your-network for more information. + Create and manage DNS records within DNS zones. See NetBird Docs https://docs.netbird.io/manage/dns/custom-zones for more information. --- # netbird_dns_record (Resource) -Create and manage DNS records within DNS zones. See [NetBird Docs](https://docs.netbird.io/how-to/manage-dns-in-your-network) for more information. +Create and manage DNS records within DNS zones. See [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information. ## Example Usage @@ -37,7 +37,16 @@ resource "netbird_dns_record" "mail" { name = "mail.example.local" type = "CNAME" content = "mail.external.com" - ttl = 3600 + ttl = 300 +} + +# Wildcard Record example +resource "netbird_dns_record" "wildcard" { + zone_id = netbird_dns_zone.example.id + name = "*.example.local" + type = "A" + content = "10.10.1.2" + ttl = 300 } ``` @@ -58,3 +67,15 @@ resource "netbird_dns_record" "mail" { ### Read-Only - `id` (String) DNS Record ID + +## Import + +Import is supported using the following syntax: + +```shell +terraform import netbird_dns_zone.example dns_zone_id + +# For example + +terraform import netbird_dns_zone.example d50lthitvgfc7398k370 +``` diff --git a/docs/resources/dns_zone.md b/docs/resources/dns_zone.md index 665ff1d..49f6932 100644 --- a/docs/resources/dns_zone.md +++ b/docs/resources/dns_zone.md @@ -3,12 +3,12 @@ page_title: "netbird_dns_zone Resource - netbird" subcategory: "" description: |- - Create and manage custom DNS zones. See NetBird Docs https://docs.netbird.io/how-to/manage-dns-in-your-network for more information. + Create and manage custom DNS zones. See NetBird Docs https://docs.netbird.io/manage/dns/custom-zones for more information. --- # netbird_dns_zone (Resource) -Create and manage custom DNS zones. See [NetBird Docs](https://docs.netbird.io/how-to/manage-dns-in-your-network) for more information. +Create and manage custom DNS zones. See [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information. ## Example Usage @@ -18,7 +18,7 @@ resource "netbird_dns_zone" "internal" { domain = "internal.company.com" enabled = true enable_search_domain = true - distribution_groups = [netbird_group.dev.id, netbird_group.ops.id] + distribution_groups = [netbird_group.example.id] } ``` @@ -39,3 +39,15 @@ resource "netbird_dns_zone" "internal" { ### Read-Only - `id` (String) DNS Zone ID + +## Import + +Import is supported using the following syntax: + +```shell +terraform import netbird_group.example group_id + +# For example + +terraform import netbird_group.example cvi609bl0ubs73ask10g +``` diff --git a/examples/data-sources/netbird_dns_record/data-source.tf b/examples/data-sources/netbird_dns_record/data-source.tf index 41a73e0..301d76d 100644 --- a/examples/data-sources/netbird_dns_record/data-source.tf +++ b/examples/data-sources/netbird_dns_record/data-source.tf @@ -1,18 +1,18 @@ # Query by ID data "netbird_dns_record" "by_id" { zone_id = netbird_dns_zone.example.id - id = "record-id-here" + id = "d50moeqtvgfc7398k38g" } # Query by name and type -data "netbird_dns_record" "www" { +data "netbird_dns_record" "by_name_and_type" { zone_id = netbird_dns_zone.example.id name = "www.example.local" type = "A" } # Query by name only -data "netbird_dns_record" "api" { +data "netbird_dns_record" "by_name" { zone_id = netbird_dns_zone.example.id name = "api.example.local" } \ No newline at end of file diff --git a/examples/data-sources/netbird_dns_zone/data-source.tf b/examples/data-sources/netbird_dns_zone/data-source.tf index d10d653..31809d7 100644 --- a/examples/data-sources/netbird_dns_zone/data-source.tf +++ b/examples/data-sources/netbird_dns_zone/data-source.tf @@ -1,10 +1,10 @@ -data "netbird_dns_zone" "example" { - name = "example-zone" +data "netbird_dns_zone" "by_name" { + name = "example.local" } # Query by ID data "netbird_dns_zone" "by_id" { - id = "zone-id-here" + id = "d50ltp59q2cs73ea7ss0" } # Query by domain diff --git a/examples/resources/netbird_dns_record/import.sh b/examples/resources/netbird_dns_record/import.sh new file mode 100644 index 0000000..fd736f0 --- /dev/null +++ b/examples/resources/netbird_dns_record/import.sh @@ -0,0 +1,5 @@ +terraform import netbird_dns_zone.example dns_zone_id + +# For example + +terraform import netbird_dns_zone.example d50lthitvgfc7398k370 \ No newline at end of file diff --git a/examples/resources/netbird_dns_record/resource.tf b/examples/resources/netbird_dns_record/resource.tf index cc74670..e52ba57 100644 --- a/examples/resources/netbird_dns_record/resource.tf +++ b/examples/resources/netbird_dns_record/resource.tf @@ -22,5 +22,14 @@ resource "netbird_dns_record" "mail" { name = "mail.example.local" type = "CNAME" content = "mail.external.com" - ttl = 3600 + ttl = 300 +} + +# Wildcard Record example +resource "netbird_dns_record" "wildcard" { + zone_id = netbird_dns_zone.example.id + name = "*.example.local" + type = "A" + content = "10.10.1.2" + ttl = 300 } \ No newline at end of file diff --git a/examples/resources/netbird_dns_zone/import.sh b/examples/resources/netbird_dns_zone/import.sh new file mode 100644 index 0000000..2d4dcfc --- /dev/null +++ b/examples/resources/netbird_dns_zone/import.sh @@ -0,0 +1,5 @@ +terraform import netbird_group.example group_id + +# For example + +terraform import netbird_group.example cvi609bl0ubs73ask10g \ No newline at end of file diff --git a/examples/resources/netbird_dns_zone/resource.tf b/examples/resources/netbird_dns_zone/resource.tf index 2ed29ca..0f4f0a4 100644 --- a/examples/resources/netbird_dns_zone/resource.tf +++ b/examples/resources/netbird_dns_zone/resource.tf @@ -3,5 +3,5 @@ resource "netbird_dns_zone" "internal" { domain = "internal.company.com" enabled = true enable_search_domain = true - distribution_groups = [netbird_group.dev.id, netbird_group.ops.id] + distribution_groups = [netbird_group.example.id] } \ No newline at end of file diff --git a/internal/provider/dns_record_data_source.go b/internal/provider/dns_record_data_source.go index 51e60f6..934aeab 100644 --- a/internal/provider/dns_record_data_source.go +++ b/internal/provider/dns_record_data_source.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + netbird "github.com/netbirdio/netbird/shared/management/client/rest" "github.com/netbirdio/netbird/shared/management/http/api" ) @@ -31,7 +32,8 @@ func (d *DNSRecordDataSource) Metadata(ctx context.Context, req datasource.Metad func (d *DNSRecordDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Read DNS Record information.", + Description: "Read DNS Record metadata.", + MarkdownDescription: "Read DNS Record metadata, see [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ MarkdownDescription: "DNS Record ID", diff --git a/internal/provider/dns_record_resource.go b/internal/provider/dns_record_resource.go index cef4980..f3e3bff 100644 --- a/internal/provider/dns_record_resource.go +++ b/internal/provider/dns_record_resource.go @@ -55,7 +55,7 @@ func (r *DNSRecord) Metadata(ctx context.Context, req resource.MetadataRequest, func (r *DNSRecord) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Create and manage DNS records within DNS zones", - MarkdownDescription: "Create and manage DNS records within DNS zones. See [NetBird Docs](https://docs.netbird.io/how-to/manage-dns-in-your-network) for more information.", + MarkdownDescription: "Create and manage DNS records within DNS zones. See [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ diff --git a/internal/provider/dns_zone_data_source.go b/internal/provider/dns_zone_data_source.go index 2937f77..c6752c8 100644 --- a/internal/provider/dns_zone_data_source.go +++ b/internal/provider/dns_zone_data_source.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" + netbird "github.com/netbirdio/netbird/shared/management/client/rest" "github.com/netbirdio/netbird/shared/management/http/api" ) @@ -32,7 +33,8 @@ func (d *DNSZoneDataSource) Metadata(ctx context.Context, req datasource.Metadat func (d *DNSZoneDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Read DNS Zone information.", + Description: "Read DNS Zone metadata.", + MarkdownDescription: "Read DNS Zone metadata, see [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ MarkdownDescription: "DNS Zone ID", diff --git a/internal/provider/dns_zone_resource.go b/internal/provider/dns_zone_resource.go index 1bc36a6..1abef30 100644 --- a/internal/provider/dns_zone_resource.go +++ b/internal/provider/dns_zone_resource.go @@ -55,7 +55,7 @@ func (r *DNSZone) Metadata(ctx context.Context, req resource.MetadataRequest, re func (r *DNSZone) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ Description: "Create and manage custom DNS zones", - MarkdownDescription: "Create and manage custom DNS zones. See [NetBird Docs](https://docs.netbird.io/how-to/manage-dns-in-your-network) for more information.", + MarkdownDescription: "Create and manage custom DNS zones. See [NetBird Docs](https://docs.netbird.io/manage/dns/custom-zones) for more information.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{