code: def terraform_runner(
      config,
      refresh=True,
      auto_approve=False,
      targets=None,
      destroy=False,
  ):
      """Terraform wrapper to build StreamAlert infrastructure.
  
      Resolves modules with `terraform get` before continuing.
  
      Args:
          config (CLIConfig): Loaded StreamAlert config
          action (str): Terraform action ('apply' or 'destroy').
          refresh (bool): If True, Terraform will refresh its state before applying the change.
          auto_approve (bool): If True, Terraform will *not* prompt the user for approval.
          targets (list): Optional list of affected targets.
              If not specified, Terraform will run against all of its resources.
  
      Returns:
          bool: True if the terraform command was successful
      """
      LOGGER.info("Initializing StreamAlert")
      if not run_command(
          ["terraform", "init"], cwd=config.build_directory
      ):
          return False
  
      LOGGER.debug("Resolving Terraform modules")
      if not run_command(
          ["terraform", "get"], cwd=config.build_directory, quiet=True
      ):
          return False
  
      tf_command = ["terraform"]
  
      if destroy:
          tf_command.append("destroy")
          # Terraform destroy has a '-force' flag instead of '-auto-approve'
          LOGGER.info("Destroying infrastructure")
          tf_command.append(
              "-force={}".format(str(auto_approve).lower())
          )
      else:
          tf_command.append("apply")
          LOGGER.info(
              "%s changes", "Applying" if auto_approve else "Planning"
          )
          tf_command.append(
              "-auto-approve={}".format(str(auto_approve).lower())
          )
  
      tf_command.append("-refresh={}".format(str(refresh).lower()))
  
      if targets:
          tf_command.extend("-target={}".format(x) for x in targets)
  
      # Build the deployment package so the Lambda does not produce an error
      # TODO: maybe remove this as packaging improvements progress
      deployment_package = package.LambdaPackage(config)
      package_path = deployment_package.create()
      if not package_path:
          return False
  
      return run_command(tf_command, cwd=config.build_directory)
  
imports: from streamalert.shared.logger import get_logger
  from streamalert_cli.helpers import run_command
  from streamalert_cli.manage_lambda import package
label_desc: Use image node_id 1 for calling a global function with example usage: terraform_runner(config, refresh, auto_approve, targets, destroy) and returns: run_command, False, False, False