How to delete a DNS record with cloudflaregetRecord?TypeScript
In Pulumi, the
cloudflare.Recordresource is used for creating, updating, and deleting DNS records in Cloudflare. However, to delete a record, we can't just fetch the record and then delete it because Pulumi does not support fetching existing resources.
In order to delete a DNS record with Cloudflare using Pulumi, you'll need the DNS record to be managed by a Pulumi program. Then you can remove the code or call
destroyon it which will trigger Pulumi to delete the DNS record in the next
Here's a TypeScript example of a program that creates a DNS record.
This program creates an "A" record for the "www" subdomain of your domain. You will have to replace
"your_domain"with the actual domain that you manage through CloudFlare.
To delete the DNS record with Cloudflare using this Pulumi program:
pulumi upto ensure that the record is being managed by Pulumi.
- Remove the resource from the Pulumi program or call
pulumi destroyon the resource.
This will delete the DNS record in Cloudflare.
The overall principle of Infrastructure as Code (IaC) tool like Pulumi is that the infrastructure is described in the code and the actual infrastructure is a reflection of the code. If the code describing the DNS record is removed or the record is marked to be destroyed, the IaC tool will make the reality match the code by deleting the DNS record.
Cloudflare Record resource documentation can provide more detailed information.