{% for group in resources -%}
resource "aws_db_parameter_group" "pg_{{ group.DBParameterGroupName | replace('.', '_') | replace('-', '_') | lower }}" {
  name        = "{{ group.DBParameterGroupName }}"
  family      = "{{ group.DBParameterGroupFamily }}"
  description = "{{ group.Description }}"

  {%- for param in group.get('Parameters', []) %}
  parameter {
    name         = "{{ param.ParameterName }}"
    value        = "{{ param.ParameterValue }}"
    apply_method = "{{ param.ApplyMethod | default('immediate') }}"
  }
  {%- endfor %}

  tags = {
    {%- for tag in group.get('Tags', []) -%}
    "{{ tag.Key }}" = "{{ tag.Value }}"
    {%- endfor %}
  }
}
{% endfor %}