code: def generate_s3_bucket(bucket, logging, **kwargs):
      """Generate an S3 Bucket dict
  
      Args:
          bucket (str): The name of the bucket
          logging (str): The S3 bucket to send access logs to
  
      Keyword Args:
          acl (str): The S3 bucket ACL
          force_destroy (bool): To enable or disable force destroy of the bucket
          sse_algorithm (str): Server-side encryption algorithm 'AES256' or 'aws:kms' (default)
          versioning (bool): To enable or disable S3 object versioning
          lifecycle_rule (dict): The S3 bucket lifecycle rule
  
      Returns:
          dict: S3 bucket Terraform dict to be used in clusters/main.tf.json
      """
      sse_algorithm = kwargs.get("sse_algorithm", "aws:kms")
  
      s3_bucket = {
          "bucket": bucket,
          "acl": kwargs.get("acl", "private"),
          "force_destroy": kwargs.get("force_destroy", True),
          "versioning": {"enabled": kwargs.get("versioning", True)},
          "logging": {
              "target_bucket": logging,
              "target_prefix": "{}/".format(bucket),
          },
          "server_side_encryption_configuration": {
              "rule": {
                  "apply_server_side_encryption_by_default": {
                      "sse_algorithm": sse_algorithm
                  }
              }
          },
          "policy": json.dumps(
              {
                  "Version": "2012-10-17",
                  "Statement": [
                      {
                          "Sid": "ForceSSLOnlyAccess",
                          "Effect": "Deny",
                          "Principal": "*",
                          "Action": "s3:*",
                          "Resource": [
                              "arn:aws:s3:::{}/*".format(bucket),
                              "arn:aws:s3:::{}".format(bucket),
                          ],
                          "Condition": {
                              "Bool": {"aws:SecureTransport": "false"}
                          },
                      }
                  ],
              }
          ),
      }
  
      if sse_algorithm == "aws:kms":
          s3_bucket["server_side_encryption_configuration"]["rule"][
              "apply_server_side_encryption_by_default"
          ][
              "kms_master_key_id"
          ] = "${aws_kms_key.server_side_encryption.key_id}"
  
      lifecycle_rule = kwargs.get("lifecycle_rule")
      if lifecycle_rule:
          s3_bucket["lifecycle_rule"] = lifecycle_rule
  
      return s3_bucket
  
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 2 for calling a global function with example usage: generate_s3_bucket(bucket, logging) and returns: s3_bucket