{% extends 'common/base_resource.tf.j2' %}
{% import 'common/macros.j2' as macros %}
{% block resources %}
{% for secret in resources %}
{{ resource_spacer() }}
resource "azurerm_key_vault_secret" "{{ secret.name_sanitized }}" {
  name         = "{{ secret.name }}"
  key_vault_id = "{{ secret.key_vault_id }}"
  value        = var.keyvault_secret_value
  
  {% if secret.content_type %}
  content_type = "{{ secret.content_type }}"
  {% endif %}
  
  {% if secret.not_before_date %}
  not_before_date = "{{ secret.not_before_date }}"
  {% endif %}
  
  {% if secret.expiration_date %}
  expiration_date = "{{ secret.expiration_date }}"
  {% endif %}

{{ macros.render_tags(secret.tags) }}

  lifecycle {
    prevent_destroy = true
    ignore_changes = [
      value
    ]
  }
}

{% endfor %}
{% endblock %}
