{% extends "common/base_resource.tf.j2" %}

{% block resources %}
{% for resource in resources %}
{{ resource_spacer() }}
resource "azurerm_servicebus_subscription" "{{ resource.name }}" {
  name     = "{{ resource.properties.name }}"
  topic_id = "{{ resource.properties.topic_id }}"
  
  {% if resource.properties.max_delivery_count is defined %}
  max_delivery_count = {{ resource.properties.max_delivery_count }}
  {% endif %}
  
  {% if resource.properties.auto_delete_on_idle is defined %}
  auto_delete_on_idle = "{{ resource.properties.auto_delete_on_idle }}"
  {% endif %}
  
  {% if resource.properties.default_message_ttl is defined %}
  default_message_ttl = "{{ resource.properties.default_message_ttl }}"
  {% endif %}
  
  {% if resource.properties.lock_duration is defined %}
  lock_duration = "{{ resource.properties.lock_duration }}"
  {% endif %}
  
  {% if resource.properties.dead_lettering_on_message_expiration is defined %}
  dead_lettering_on_message_expiration = {{ resource.properties.dead_lettering_on_message_expiration | lower }}
  {% endif %}
  
  {% if resource.properties.dead_lettering_on_filter_evaluation_error is defined %}
  dead_lettering_on_filter_evaluation_error = {{ resource.properties.dead_lettering_on_filter_evaluation_error | lower }}
  {% endif %}
  
  {% if resource.properties.enable_batched_operations is defined %}
  enable_batched_operations = {{ resource.properties.enable_batched_operations | lower }}
  {% endif %}
  
  {% if resource.properties.requires_session is defined %}
  requires_session = {{ resource.properties.requires_session | lower }}
  {% endif %}
  
  {% if resource.properties.forward_to is defined %}
  forward_to = "{{ resource.properties.forward_to }}"
  {% endif %}
  
  {% if resource.properties.forward_dead_lettered_messages_to is defined %}
  forward_dead_lettered_messages_to = "{{ resource.properties.forward_dead_lettered_messages_to }}"
  {% endif %}
  
  {% if resource.properties.status is defined %}
  status = "{{ resource.properties.status }}"
  {% endif %}
}

{% endfor %}
{% endblock %}
