docstr: Initialize infrastructure using Terraform
  
  Args:
      config (CLIConfig): Loaded StreamAlert config
  
  Returns:
      bool: False if errors occurred, True otherwise
docstr_tok: ["Initialize","infrastructure","using","Terraform","Args",":","config","(","CLIConfig",")",":","Loaded","StreamAlert","config","Returns",":","bool",":","False","if","errors","occurred",",","True","otherwise"]
code: def handler(cls, options, config):
      """Initialize infrastructure using Terraform
  
      Args:
          config (CLIConfig): Loaded StreamAlert config
  
      Returns:
          bool: False if errors occurred, True otherwise
      """
      LOGGER.info("Initializing StreamAlert")
  
      # generate init Terraform files
      if not terraform_generate_handler(config=config, init=True):
          return False
  
      LOGGER.info("Initializing Terraform")
      if not run_command(
          ["terraform", "init"], cwd=config.build_directory
      ):
          return False
  
      # build init infrastructure
      LOGGER.info("Building initial infrastructure")
      init_targets = [
          "aws_s3_bucket.lambda_source",
          "aws_s3_bucket.logging_bucket",
          "aws_s3_bucket.streamalert_secrets",
          "aws_s3_bucket.terraform_remote_state",
          "aws_s3_bucket.streamalerts",
          "aws_kms_key.server_side_encryption",
          "aws_kms_alias.server_side_encryption",
          "aws_kms_key.streamalert_secrets",
          "aws_kms_alias.streamalert_secrets",
          "module.streamalert_athena",  # required for the alerts table
          "aws_dynamodb_table.terraform_remote_state_lock",
      ]
  
      # this bucket must exist before the log tables can be created, but
      # shouldn't be created unless the firehose is enabled
      if (
          config["global"]["infrastructure"]
          .get("firehose", {})
          .get("enabled")
      ):
          init_targets.append("aws_s3_bucket.streamalert_data")
  
      if not terraform_runner(config, targets=init_targets):
          LOGGER.error(
              "An error occurred while running StreamAlert init"
          )
          return False
  
      # generate the main.tf with remote state enabled
      LOGGER.info("Configuring Terraform Remote State")
      if not terraform_generate_handler(
          config=config, check_tf=False, check_creds=False
      ):
          return False
  
      if not run_command(
          ["terraform", "init"], cwd=config.build_directory
      ):
          return False
  
      LOGGER.info("Deploying Lambda Functions")
  
      functions = [
          "rule",
          "alert",
          "alert_merger",
          "athena",
          "classifier",
      ]
  
      deploy(config, functions)
  
      # we need to manually create the streamalerts table since terraform does not support this
      # See: https://github.com/terraform-providers/terraform-provider-aws/issues/1486
      if get_data_file_format(config) == "json":
          # Terraform v0.12 now supports creating Athena tables. We will support
          # to use terraform aws_glue_catalog_table resource to create table only
          # when data file_format is set to "parquet" in "athena_partitioner_config"
          #
          # For "json" file_format, we will continue using Athena DDL query to
          # create tables. However, this capabity will be faded out in the future
          # release because we want users to take advantage of parquet performance.
          alerts_bucket = firehose_alerts_bucket(config)
          create_table("alerts", alerts_bucket, config)
  
          # Create the glue catalog tables for the enabled logs
          if not create_log_tables(config=config):
              return
  
      LOGGER.info("Building remaining infrastructure")
      return terraform_runner(config, refresh=False)
  
imports: from fnmatch import fnmatch
  import json
  import os
  from streamalert.shared.config import firehose_alerts_bucket
  from streamalert.shared.logger import get_logger
  from streamalert.shared.utils import get_data_file_format
  from streamalert_cli.athena.handler import create_table, create_log_tables
  from streamalert_cli.helpers import check_credentials, continue_prompt, run_command
  from streamalert_cli.manage_lambda.deploy import deploy
  from streamalert_cli.terraform.generate import terraform_generate_handler
  from streamalert_cli.terraform.helpers import terraform_check, terraform_runner
  from streamalert_cli.utils import add_clusters_arg, CLICommand, set_parser_epilog, UniqueSortedListAction
label_desc: Use image node_id 2 for calling the TerraformInitCommand obj's underlying member method code with example usage: obj.handler(cls, options, config) and returns: terraform_runner, False, False, False, False, False