コード例 #1
0
    def test_generate_cloudwatch_destinations(self):
        """CLI - Terraform Generate CloudWatch Destinations"""
        cloudwatch_destinations.generate_cloudwatch_destinations(
            'advanced',
            self.cluster_dict,
            self.config
        )

        expected = {
            'cloudwatch_logs_destination_advanced': {
                'source': './modules/tf_cloudwatch_logs_destination',
                'prefix': 'unit-test',
                'cluster': 'advanced',
                'regions': [
                    'us-east-2',
                    'us-west-2'
                ],
                'destination_kinesis_stream_arn': '${module.kinesis_advanced.arn}'
            },
            'cloudwatch_logs_destination_advanced_us-east-2': {
                'source': './modules/tf_cloudwatch_logs_destination/modules/destination',
                'prefix': 'unit-test',
                'cluster': 'advanced',
                'account_ids': [
                    '123456789012'
                ],
                '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-east-2'
                }
            },
            'cloudwatch_logs_destination_advanced_us-west-2': {
                'source': './modules/tf_cloudwatch_logs_destination/modules/destination',
                'prefix': 'unit-test',
                'cluster': 'advanced',
                'account_ids': [
                    '123456789012'
                ],
                '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-2'
                }
            }
        }

        assert_equal(expected, self.cluster_dict['module'])
コード例 #2
0
ファイル: generate.py プロジェクト: tompiscitell/streamalert
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