class_docstr: Test class for the Terraform Cluster Generating
class_docstr_tok: ["Test","class","for","the","Terraform","Cluster","Generating"]
docstr: CLI - Terraform Generate Main
docstr_tok: ["CLI","-","Terraform","Generate","Main"]
code: def test_generate_main(self):
      """CLI - Terraform Generate Main"""
      tf_main = generate.generate_main(config=self.config, init=False)
  
      tf_main_expected = {
          "terraform": {
              "backend": {
                  "s3": {
                      "bucket": "unit-test-streamalert-terraform-state",
                      "key": "streamalert_state/terraform.tfstate",
                      "region": "us-west-1",
                      "dynamodb_table": "unit-test_streamalert_terraform_state_lock",
                      "encrypt": True,
                      "acl": "private",
                      "kms_key_id": "alias/alternate-alias",
                  }
              }
          },
          "resource": {
              "aws_kms_key": {
                  "server_side_encryption": {
                      "enable_key_rotation": True,
                      "description": "StreamAlert S3 Server-Side Encryption",
                      "policy": ANY,
                  },
                  "streamalert_secrets": {
                      "enable_key_rotation": True,
                      "description": "StreamAlert secret management",
                  },
              },
              "aws_kms_alias": {
                  "server_side_encryption": {
                      "name": "alias/unit-test_server-side-encryption",
                      "target_key_id": "${aws_kms_key.server_side_encryption.key_id}",
                  },
                  "streamalert_secrets": {
                      "name": "alias/alternate-alias",
                      "target_key_id": "${aws_kms_key.streamalert_secrets.key_id}",
                  },
              },
              "aws_dynamodb_table": {
                  "terraform_remote_state_lock": {
                      "name": "unit-test_streamalert_terraform_state_lock",
                      "billing_mode": "PAY_PER_REQUEST",
                      "hash_key": "LockID",
                      "attribute": {"name": "LockID", "type": "S"},
                      "tags": {"Name": "StreamAlert"},
                  }
              },
              "aws_s3_bucket": {
                  "terraform_remote_state": {
                      "bucket": "unit-test-streamalert-terraform-state",
                      "acl": "private",
                      "force_destroy": True,
                      "versioning": {"enabled": True},
                      "logging": {
                          "target_bucket": "unit-test-streamalert-s3-logging",
                          "target_prefix": "unit-test-streamalert-terraform-state/",
                      },
                      "server_side_encryption_configuration": {
                          "rule": {
                              "apply_server_side_encryption_by_default": {
                                  "sse_algorithm": "aws:kms",
                                  "kms_master_key_id": (
                                      "${aws_kms_key.server_side_encryption.key_id}"
                                  ),
                              }
                          }
                      },
                      "policy": ANY,
                  },
                  "logging_bucket": {
                      "bucket": "unit-test-streamalert-s3-logging",
                      "acl": "log-delivery-write",
                      "force_destroy": True,
                      "versioning": {"enabled": True},
                      "logging": {
                          "target_bucket": "unit-test-streamalert-s3-logging",
                          "target_prefix": "unit-test-streamalert-s3-logging/",
                      },
                      "lifecycle_rule": {
                          "prefix": "/",
                          "enabled": True,
                          "transition": {
                              "days": 365,
                              "storage_class": "GLACIER",
                          },
                      },
                      "server_side_encryption_configuration": {
                          "rule": {
                              "apply_server_side_encryption_by_default": {
                                  "sse_algorithm": "AES256"
                              }
                          }
                      },
                      "policy": ANY,
                  },
                  "streamalerts": {
                      "bucket": "unit-test-streamalerts",
                      "acl": "private",
                      "force_destroy": True,
                      "versioning": {"enabled": True},
                      "logging": {
                          "target_bucket": "unit-test-streamalert-s3-logging",
                          "target_prefix": "unit-test-streamalerts/",
                      },
                      "server_side_encryption_configuration": {
                          "rule": {
                              "apply_server_side_encryption_by_default": {
                                  "sse_algorithm": "aws:kms",
                                  "kms_master_key_id": (
                                      "${aws_kms_key.server_side_encryption.key_id}"
                                  ),
                              }
                          }
                      },
                      "policy": ANY,
                  },
              },
              "aws_sns_topic": {
                  "monitoring": {
                      "name": "unit-test_streamalert_monitoring"
                  }
              },
          },
      }
  
      assert_dict_equal(
          tf_main["terraform"], tf_main_expected["terraform"]
      )
      assert_dict_equal(
          tf_main["resource"], tf_main_expected["resource"]
      )
  
imports: from mock import ANY, Mock, patch
  from nose.tools import assert_equal, assert_dict_equal, assert_false, assert_raises, assert_true
  from streamalert.shared.exceptions import ConfigError
  from streamalert_cli.config import CLIConfig
  from streamalert_cli.terraform import common, cloudtrail, cloudwatch_destinations, cloudwatch_events, flow_logs, generate
label_desc: Use image node_id 4 for calling the TestTerraformGenerate obj's underlying member method code with example usage: obj.test_generate_main() without return types