My goal is to schedule a Cron Job using GitHub Actions to destroy and reapply the same resource at specific times — for example, apply at 8 a.m. and destroy at 5 p.m.
Based on my research, I would run the command terraform destroy -target=xyz.resource_block_name.
Now, if I want to redeploy the exact same resource, would I run terraform apply -target=xyz.resource_block_name? Will this command apply only the Terraform code for that specific resource block (which configures the bastion host) and nothing else?
Also, will this create a new resource ID in Azure?
The Terraform code remains in the repository with the same resource block configuration — the only difference is that terraform destroy removed that resource from the state file.
Thank you.