github.com/Hashicorp/terraform@v0.11.12-beta1/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  	// Stop is called when the provisioner should halt any in-flight actions.
    26  	//
    27  	// This can be used to make a nicer Ctrl-C experience for Terraform.
    28  	// Even if this isn't implemented to do anything (just returns nil),
    29  	// Terraform will still cleanly stop after the currently executing
    30  	// graph node is complete. However, this API can be used to make more
    31  	// efficient halts.
    32  	//
    33  	// Stop doesn't have to and shouldn't block waiting for in-flight actions
    34  	// to complete. It should take any action it wants and return immediately
    35  	// acknowledging it has received the stop request. Terraform core will
    36  	// automatically not make any further API calls to the provider soon
    37  	// after Stop is called (technically exactly once the currently executing
    38  	// graph nodes are complete).
    39  	//
    40  	// The error returned, if non-nil, is assumed to mean that signaling the
    41  	// stop somehow failed and that the user should expect potentially waiting
    42  	// a longer period of time.
    43  	Stop() error
    44  }
    45  
    46  // ResourceProvisionerCloser is an interface that provisioners that can close
    47  // connections that aren't needed anymore must implement.
    48  type ResourceProvisionerCloser interface {
    49  	Close() error
    50  }
    51  
    52  // ResourceProvisionerFactory is a function type that creates a new instance
    53  // of a resource provisioner.
    54  type ResourceProvisionerFactory func() (ResourceProvisioner, error)