New to Kestra?
Use blueprints to kickstart your first workflows.
Destroy a GCP VM with Terraform from shared state, then remove its Active Directory account and DNS A/PTR records via Ansible over WinRM with Kestra.
Deleting a VM is the easy part; the orphaned AD computer account and stale DNS records are what bite you later. This blueprint does the full teardown: Terraform destroys the Google Cloud instance from the same remote state that provisioned it, the VM asset is flipped to state: deleted, and an Ansible playbook connects to your Windows domain controller over WinRM to remove the computer account, the forward A record, and the reverse PTR record.
deleteVM task (io.kestra.plugin.terraform.cli.TerraformCLI) reconstructs the instance definition from the flow inputs, runs terraform init -backend-config="prefix={{ inputs.vmName }}" against a shared GCS backend so each VM has its own state prefix, and executes terraform destroy -auto-approve -json. Its assets block records lineage and marks the io.kestra.plugin.ee.assets.VM asset deleted.removeDNSentry task (io.kestra.plugin.ansible.cli.AnsibleCLI) installs pywinrm, builds a WinRM inventory from the dcConfig KV record published by the domain controller deployment flow, and runs a playbook whose ansible.windows.win_shell task calls Remove-ADComputer, then Remove-DnsServerResourceRecord for both the A record in the domain zone and the PTR record in the computed in-addr.arpa reverse zone.kv('dcConfig').subnetCIDR and the VM's IP octets, so no DNS math is hardcoded.Terraform knows nothing about your directory or DNS zones, and Ansible has no idea which Terraform state to touch. Kestra binds them: shared inputs drive both tools, the KV store carries the domain controller's connection details between flows, secrets stay out of playbooks, and the execution log proves that the instance, the AD account, and both DNS records were removed in one auditable run.
dcConfig KV record with externalIPAddress, username, domainName, and subnetCIDR (created by the companion AD controller blueprint).assets block to run on OSS).GCP_SERVICE_ACCOUNT_JSON: JSON key of the service account allowed to delete instances and read the state bucket.AD_ADMIN_PASSWORD: password of the AD admin user Ansible connects with.backend.tf and align main.tf with your provisioning configuration.dcConfig KV entry exists (deploy the AD controller blueprint first).vmName and ipAddress; verify the instance, AD account, and DNS records are gone.io.kestra.plugin.core.flow.Pause approval gate before the destroy for production hosts.io.kestra.plugin.notifications.slack.SlackIncomingWebhook when cleanup completes.io.kestra.plugin.core.http.Request task.SELECT input using the assets() function.