github.com/kanishk98/terraform@v1.3.0-dev.0.20220917174235-661ca8088a6a/website/docs/language/resources/provisioners/null_resource.mdx (about) 1 --- 2 page_title: Provisioners Without a Resource 3 description: >- 4 A null_resource allows you to configure provisioners that are not directly 5 associated with a single existing resource. 6 --- 7 8 # Provisioners Without a Resource 9 10 [null]: https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource 11 12 If you need to run provisioners that aren't directly associated with a specific 13 resource, you can associate them with a `null_resource`. 14 15 Instances of [`null_resource`][null] are treated like normal resources, but they 16 don't do anything. Like with any other resource, you can configure 17 [provisioners](/language/resources/provisioners/syntax) and [connection 18 details](/language/resources/provisioners/connection) on a `null_resource`. You can also 19 use its `triggers` argument and any meta-arguments to control exactly where in 20 the dependency graph its provisioners will run. 21 22 ~> **Important:** Use provisioners as a last resort. There are better alternatives for most situations. Refer to 23 [Declaring Provisioners](/language/resources/provisioners/syntax) for more details. 24 25 ## Example usage 26 27 ```hcl 28 resource "aws_instance" "cluster" { 29 count = 3 30 31 # ... 32 } 33 34 resource "null_resource" "cluster" { 35 # Changes to any instance of the cluster requires re-provisioning 36 triggers = { 37 cluster_instance_ids = "${join(",", aws_instance.cluster.*.id)}" 38 } 39 40 # Bootstrap script can run on any instance of the cluster 41 # So we just choose the first in this case 42 connection { 43 host = "${element(aws_instance.cluster.*.public_ip, 0)}" 44 } 45 46 provisioner "remote-exec" { 47 # Bootstrap script called with private_ip of each node in the cluster 48 inline = [ 49 "bootstrap-cluster.sh ${join(" ", aws_instance.cluster.*.private_ip)}", 50 ] 51 } 52 } 53 ``` 54 55 ## Argument Reference 56 57 In addition to meta-arguments supported by all resources, `null_resource` 58 supports the following specific arguments: 59 60 - `triggers` - A map of values which should cause this set of provisioners to 61 re-run. Values are meant to be interpolated references to variables or 62 attributes of other resources.