code: def generate_cloudwatch_events(cluster_name, cluster_dict, config):
      """Add the CloudWatch Events module to the Terraform cluster dict.
  
      Args:
          cluster_name (str): The name of the currently generating cluster
          cluster_dict (defaultdict): The dict containing all Terraform config for a given cluster.
          config (dict): The loaded config from the 'conf/' directory
  
      Returns:
          bool: Result of applying the cloudwatch events module
      """
      modules = config["clusters"][cluster_name]["modules"]
      settings = modules["cloudwatch_events"]
      if not settings.get("enabled", True):
          LOGGER.debug("CloudWatch events module is not enabled")
          return True  # not an error
  
      tf_module_name = "cloudwatch_events_{}".format(cluster_name)
  
      # Using this syntax to allow for override via empty event pattern
      event_pattern = None
      if "event_pattern" in settings:
          event_pattern = settings["event_pattern"]
          if event_pattern and not set(event_pattern).issubset(
              VALID_EVENT_PATTERN_KEYS
          ):
              LOGGER.error(
                  "Invalid CloudWatch event pattern: %s",
                  json.dumps(event_pattern),
              )
              return False
      else:
          event_pattern = {
              "account": [config["global"]["account"]["aws_account_id"]]
          }
  
      cluster_dict["module"][tf_module_name] = {
          "source": "./modules/tf_cloudwatch_events",
          "cluster": cluster_name,
          "prefix": config["global"]["account"]["prefix"],
          "kinesis_arn": "${{module.kinesis_{}.arn}}".format(
              cluster_name
          ),
          # None == null in json objects and terraform 12 supports null variables
          "event_pattern": json.dumps(event_pattern)
          if event_pattern is not None
          else event_pattern,
      }
  
      cross_account_settings = settings.get("cross_account")
      if not cross_account_settings:
          return True
  
      region_map = _map_regions(cross_account_settings)
      for region, values in region_map.items():
          tf_module_name = (
              "cloudwatch_events_cross_account_{}_{}".format(
                  cluster_name, region
              )
          )
          cluster_dict["module"][tf_module_name] = {
              "source": "./modules/tf_cloudwatch_events/cross_account",
              "region": region,
              "accounts": sorted(values.get("accounts", [])),
              "organizations": sorted(values.get("organizations", [])),
              "providers": {
                  # use the aliased provider for this region from providers.tf
                  "aws": "aws.{}".format(region)
              },
          }
  
      return True
  
imports: from collections import defaultdict
  import json
  from streamalert.shared.logger import get_logger
label_desc: Use image node_id 1 for calling a global function with example usage: generate_cloudwatch_events(cluster_name, cluster_dict, config) and returns: True, True, True, False