github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/provisioners/null_resource.html.markdown (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Provisioners: null_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 exiting resource.
     8  ---
     9  
    10  # null\_resource
    11  
    12  The `null_resource` is a resource that allows you to configure provisioners
    13  that are not directly associated with a single existing resource.
    14  
    15  A `null_resource` behaves exactly like any other resource, so you configure
    16  [provisioners](/docs/provisioners/index.html), [connection
    17  details](/docs/provisioners/connection.html), and other meta-parameters in the
    18  same way you would on any other resource.
    19  
    20  This allows fine-grained control over when provisioners run in the dependency
    21  graph.
    22  
    23  ## Example usage
    24  
    25  ```
    26  # Bootstrap a cluster after all its instances are up
    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 clutser
    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 all the resource configuration available, `null_resource` supports the following specific configuration options:
    57  
    58   * `triggers` - A mapping of values which should trigger a rerun of this set of
    59     provisioners. Values are meant to be interpolated references to variables or
    60     attributes of other resources.
    61