// Apply executes the remote exec provisioner func (p *ResourceProvisioner) Apply( o terraform.UIOutput, s *terraform.InstanceState, c *terraform.ResourceConfig) error { // Get a new communicator comm, err := communicator.New(s) if err != nil { return err } // Collect the scripts scripts, err := p.collectScripts(c) if err != nil { return err } for _, s := range scripts { defer s.Close() } // Copy and execute each script if err := p.runScripts(o, comm, scripts); err != nil { return err } return nil }