{% for log_group in resources -%}
resource "aws_cloudwatch_log_group" "lg_{{ log_group.name_sanitized }}" {
  name = "{{ log_group.logGroupName }}"

  {%- if log_group.get('retentionInDays') %}
  retention_in_days = {{ log_group.retentionInDays }}
  {%- endif %}

  {%- if log_group.get('kmsKeyId') %}
  kms_key_id = "{{ log_group.kmsKeyId }}"
  {%- endif %}

  tags = {
    {%- for key, value in log_group.get('tags', {}).items() -%}
    "{{ key }}" = "{{ value }}"
    {%- endfor %}
  }
}
{% endfor %}