github.com/gettyimages/terraform@v0.7.6-0.20161219132226-dc052c5707a3/terraform/resource_provisioner.go (about)

     1  package terraform
     2  
     3  // ResourceProvisioner is an interface that must be implemented by any
     4  // resource provisioner: the thing that initializes resources in
     5  // a Terraform configuration.
     6  type ResourceProvisioner interface {
     7  	// Validate is called once at the beginning with the raw
     8  	// configuration (no interpolation done) and can return a list of warnings
     9  	// and/or errors.
    10  	//
    11  	// This is called once per resource.
    12  	//
    13  	// This should not assume any of the values in the resource configuration
    14  	// are valid since it is possible they have to be interpolated still.
    15  	// The primary use case of this call is to check that the required keys
    16  	// are set and that the general structure is correct.
    17  	Validate(*ResourceConfig) ([]string, []error)
    18  
    19  	// Apply runs the provisioner on a specific resource and returns the new
    20  	// resource state along with an error. Instead of a diff, the ResourceConfig
    21  	// is provided since provisioners only run after a resource has been
    22  	// newly created.
    23  	Apply(UIOutput, *InstanceState, *ResourceConfig) error
    24  }
    25  
    26  // ResourceProvisionerCloser is an interface that provisioners that can close
    27  // connections that aren't needed anymore must implement.
    28  type ResourceProvisionerCloser interface {
    29  	Close() error
    30  }
    31  
    32  // ResourceProvisionerFactory is a function type that creates a new instance
    33  // of a resource provisioner.
    34  type ResourceProvisionerFactory func() (ResourceProvisioner, error)