code: def _generate_global_module(config):
      # 2019-08-22 (Ryxias)
      #   In version 3.0.0+, StreamAlert will default to always using the prefix, when "use_prefix"
      #   is not present.
      #
      #   Refer to this PR for more information: https://github.com/airbnb/streamalert/pull/979
      use_prefix = (
          config["global"]["infrastructure"]
          .get("classifier_sqs", {})
          .get("use_prefix", True)
      )
  
      global_module = {
          "source": "./modules/tf_globals",
          "account_id": config["global"]["account"]["aws_account_id"],
          "region": config["global"]["account"]["region"],
          "prefix": config["global"]["account"]["prefix"],
          "kms_key_arn": "${aws_kms_key.server_side_encryption.arn}",
          "rules_engine_timeout": config["lambda"][
              "rules_engine_config"
          ]["timeout"],
          "sqs_use_prefix": use_prefix,
          "alerts_db_name": get_database_name(config),
          "alerts_file_format": get_data_file_format(config),
          "alerts_schema": generate_alerts_table_schema(),
      }
  
      # The below code applies settings for resources only if the settings are explicitly
      # defined. This is because these resources have defaults defined in the
      # ./modules/tf_globals module. This will allow for overriding these setting, but
      # avoids storing defaults in mulitple locations
      if "alerts_table" in config["global"]["infrastructure"]:
          for setting in {"read_capacity", "write_capacity"}:
              value = config["global"]["infrastructure"][
                  "alerts_table"
              ].get(setting)
              if value:
                  global_module[
                      "alerts_table_{}".format(setting)
                  ] = value
  
      alert_fh_settings_with_defaults = {
          "bucket_name",
          "buffer_size",
          "buffer_interval",
          "cloudwatch_log_retention",
      }
  
      if "alerts_firehose" in config["global"]["infrastructure"]:
          for setting in alert_fh_settings_with_defaults:
              value = config["global"]["infrastructure"][
                  "alerts_firehose"
              ].get(setting)
              if not value:
                  continue
  
              global_module[
                  "alerts_firehose_{}".format(setting)
              ] = value
  
      if "rule_staging" in config["global"]["infrastructure"]:
          if config["global"]["infrastructure"]["rule_staging"].get(
              "enabled"
          ):
              global_module["enable_rule_staging"] = True
              for setting in {
                  "table_read_capacity",
                  "table_write_capacity",
              }:
                  value = config["global"]["infrastructure"][
                      "rule_staging"
                  ].get(setting)
                  if value:
                      # Defaults are set for this in the terraform module, so skip
                      global_module["rules_{}".format(setting)] = value
  
      return global_module
  
imports: import json
  import os
  from streamalert.shared.config import ConfigError, firehose_alerts_bucket
  from streamalert.shared.logger import get_logger
  from streamalert.shared.utils import get_database_name, get_data_file_format
  from streamalert_cli.athena.helpers import generate_alerts_table_schema
  from streamalert_cli.helpers import check_credentials
  from streamalert_cli.terraform.common import InvalidClusterName, infinitedict, monitoring_topic_name, s3_access_logging_bucket, terraform_state_bucket
  from streamalert_cli.terraform.artifact_extractor import generate_artifact_extractor
  from streamalert_cli.terraform.alert_merger import generate_alert_merger
  from streamalert_cli.terraform.alert_processor import generate_alert_processor
  from streamalert_cli.terraform.apps import generate_apps
  from streamalert_cli.terraform.athena import generate_athena
  from streamalert_cli.terraform.cloudtrail import generate_cloudtrail
  from streamalert_cli.terraform.cloudwatch_destinations import generate_cloudwatch_destinations
  from streamalert_cli.terraform.cloudwatch_events import generate_cloudwatch_events
  from streamalert_cli.terraform.firehose import generate_firehose
  from streamalert_cli.terraform.flow_logs import generate_flow_logs
  from streamalert_cli.terraform.helpers import terraform_check
  from streamalert_cli.terraform.kinesis_events import generate_kinesis_events
  from streamalert_cli.terraform.kinesis_streams import generate_kinesis_streams
  from streamalert_cli.terraform.metrics import generate_aggregate_cloudwatch_metric_alarms, generate_aggregate_cloudwatch_metric_filters, generate_cluster_cloudwatch_metric_filters, generate_cluster_cloudwatch_metric_alarms
  from streamalert_cli.terraform.monitoring import generate_monitoring
  from streamalert_cli.terraform.rule_promotion import generate_rule_promotion
  from streamalert_cli.terraform.classifier import generate_classifier
  from streamalert_cli.terraform.rules_engine import generate_rules_engine
  from streamalert_cli.terraform.s3_events import generate_s3_events
  from streamalert_cli.terraform.scheduled_queries import generate_scheduled_queries_module_configuration
  from streamalert_cli.terraform.threat_intel_downloader import generate_threat_intel_downloader
  from streamalert_cli.utils import CLICommand
label_desc: Use image node_id 11 for calling a global function with example usage: _generate_global_module(config) and returns: global_module