def _tf_metric_alarms(lambda_config, sns_arn):
    """Compute metric alarm Terraform configuration from the Lambda config."""
    result = {}
    alarms_config = lambda_config.get('metric_alarms', {})
    if not alarms_config:
        return result

    result['alarm_actions'] = [sns_arn]

    for alarm_type in ['errors', 'throttles']:
        settings = alarms_config.get(alarm_type)
        if not settings:
            continue

        for key in ['enabled', 'evaluation_periods', 'period_secs', 'threshold']:
            if key in settings:
                result['{}_alarm_{}'.format(alarm_type, key)] = settings[key]

    return result