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