def test_generate_flow_logs(self): """CLI - Terraform Generate Flow Logs""" cluster_name = 'advanced' flow_logs.generate_flow_logs(cluster_name, self.cluster_dict, self.config) expected = { 'module': { 'flow_logs_advanced': { 'source': './modules/tf_flow_logs', 'prefix': 'unit-test', 'cluster': 'advanced', 'cloudwatch_logs_destination_arn': ('${module.cloudwatch_logs_destination_advanced_us-west-1.' 'cloudwatch_logs_destination_arn}'), 'vpcs': ['vpc-id-1', 'vpc-id-2'], }, 'cloudwatch_logs_destination_advanced': { 'source': './modules/tf_cloudwatch_logs_destination', 'prefix': 'unit-test', 'cluster': 'advanced', 'regions': ['us-west-1'], 'destination_kinesis_stream_arn': '${module.kinesis_advanced.arn}' }, 'cloudwatch_logs_destination_advanced_us-west-1': { 'source': './modules/tf_cloudwatch_logs_destination/modules/destination', 'prefix': 'unit-test', 'cluster': 'advanced', 'account_ids': ['12345678910'], 'destination_kinesis_stream_arn': '${module.kinesis_advanced.arn}', 'cloudwatch_logs_subscription_role_arn': ('${module.cloudwatch_logs_destination_advanced.' 'cloudwatch_logs_subscription_role_arn}'), 'providers': { 'aws': 'aws.us-west-1' } } } } assert_equal(self.cluster_dict, expected)
def generate_cluster(config, cluster_name): """Generate a StreamAlert cluster file. Args: config (dict): The loaded config from the 'conf/' directory cluster_name (str): The name of the currently generating cluster Returns: dict: generated Terraform cluster dictionary """ modules = config['clusters'][cluster_name]['modules'] cluster_dict = infinitedict() generate_classifier(cluster_name, cluster_dict, config) generate_cluster_cloudwatch_metric_filters(cluster_name, cluster_dict, config) generate_cluster_cloudwatch_metric_alarms(cluster_name, cluster_dict, config) if modules.get('cloudwatch_monitoring', {}).get('enabled'): if not generate_monitoring(cluster_name, cluster_dict, config): return if modules.get('kinesis'): if not generate_kinesis_streams(cluster_name, cluster_dict, config): return if modules.get('kinesis_events'): if not generate_kinesis_events(cluster_name, cluster_dict, config): return if modules.get('cloudtrail'): if not generate_cloudtrail(cluster_name, cluster_dict, config): return # purposely not using .get, since no extra settings are required for this module if 'cloudwatch_events' in modules: if not generate_cloudwatch_events(cluster_name, cluster_dict, config): return if modules.get('cloudwatch_logs_destination'): if not generate_cloudwatch_destinations(cluster_name, cluster_dict, config): return if modules.get('flow_logs'): if not generate_flow_logs(cluster_name, cluster_dict, config): return if modules.get('s3_events'): if not generate_s3_events(cluster_name, cluster_dict, config): return generate_apps(cluster_name, cluster_dict, config) return cluster_dict