What are `terraform_data` and `null_resource`?
IntermediateConceptProviders, Resources and Data Sources
Answer
Both are resources that do nothing themselves but hold values or attach provisioners and triggers. terraform_data (built in, Terraform 1.4+) replaces null_resource from the null provider; it has input and triggers_replace to force recreation when a value changes.
resource "terraform_data" "bootstrap" {
triggers_replace = [aws_instance.web.id]
provisioner "local-exec" { command = "./register.sh" }
}
More on Providers, Resources and Data Sources
What is a resource block and how is it addressed?BeginnerWhat is the difference between a resource and a data source?BeginnerHow do you configure a provider such as AWS?BeginnerHow do you use the same provider with multiple regions or accounts?IntermediateIn what order does the AWS provider look for credentials?IntermediateWhat does `default_tags` in the AWS provider do and what are its pitfalls?Intermediate