diff --git a/.changelog/3084.txt b/.changelog/3084.txt new file mode 100644 index 0000000000..7a5433cf48 --- /dev/null +++ b/.changelog/3084.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +datasource/cloudflare_record: Add the option to filter by "content" +``` \ No newline at end of file diff --git a/docs/data-sources/record.md b/docs/data-sources/record.md index e0d50eae3a..15b1ee5cc3 100644 --- a/docs/data-sources/record.md +++ b/docs/data-sources/record.md @@ -27,6 +27,7 @@ data "cloudflare_record" "example" { ### Optional +- `content` (String) Content to filter record results on. - `priority` (Number) DNS priority to filter record results on. - `type` (String) DNS record type to filter record results on. Defaults to `A`. diff --git a/internal/sdkv2provider/data_source_record.go b/internal/sdkv2provider/data_source_record.go index 8fef93ba37..4852dc1952 100644 --- a/internal/sdkv2provider/data_source_record.go +++ b/internal/sdkv2provider/data_source_record.go @@ -36,6 +36,11 @@ func dataSourceCloudflareRecord() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{"A", "AAAA", "CAA", "CNAME", "TXT", "SRV", "LOC", "MX", "NS", "SPF", "CERT", "DNSKEY", "DS", "NAPTR", "SMIMEA", "SSHFP", "TLSA", "URI", "PTR", "HTTPS", "SVCB"}, false), Description: "DNS record type to filter record results on.", }, + "content": { + Type: schema.TypeString, + Optional: true, + Description: "Content to filter record results on.", + }, "priority": { Type: schema.TypeInt, Optional: true, @@ -81,8 +86,9 @@ func dataSourceCloudflareRecordRead(ctx context.Context, d *schema.ResourceData, zoneID := d.Get(consts.ZoneIDSchemaKey).(string) searchRecord := cloudflare.ListDNSRecordsParams{ - Name: d.Get("hostname").(string), - Type: d.Get("type").(string), + Name: d.Get("hostname").(string), + Type: d.Get("type").(string), + Content: d.Get("content").(string), } records, _, err := client.ListDNSRecords(ctx, cloudflare.ZoneIdentifier(zoneID), searchRecord)