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

{% block resources %}
{% for resource in resources %}
{{ resource_spacer() }}
resource "azurerm_mssql_database_extended_auditing_policy" "{{ resource.name }}" {
  database_id = "{{ resource.properties.database_id }}"
  
  {% if resource.properties.storage_endpoint is defined %}
  storage_endpoint = "{{ resource.properties.storage_endpoint }}"
  {% endif %}
  
  {% if resource.properties.storage_account_access_key is defined %}
  storage_account_access_key = "{{ resource.properties.storage_account_access_key }}"
  {% endif %}
  
  {% if resource.properties.storage_account_access_key_is_secondary is defined %}
  storage_account_access_key_is_secondary = {{ resource.properties.storage_account_access_key_is_secondary | lower }}
  {% endif %}
  
  {% if resource.properties.retention_in_days is defined %}
  retention_in_days = {{ resource.properties.retention_in_days }}
  {% endif %}
  
  {% if resource.properties.log_monitoring_enabled is defined %}
  log_monitoring_enabled = {{ resource.properties.log_monitoring_enabled | lower }}
  {% endif %}
  
  {% if resource.properties.enabled is defined %}
  enabled = {{ resource.properties.enabled | lower }}
  {% endif %}
}

{% endfor %}
{% endblock %}
