{% for attachment in resources -%}
resource "aws_lb_target_group_attachment" "tg_attach_{{ attachment.name_sanitized }}" {
  target_group_arn = "{{ attachment.TargetGroupArn }}"
  target_id        = "{{ attachment.TargetId }}"
  
  {%- if attachment.Port %}
  port             = {{ attachment.Port }}
  {%- endif %}
  
  {%- if attachment.AvailabilityZone %}
  availability_zone = "{{ attachment.AvailabilityZone }}"
  {%- endif %}

  # Current health status: {{ attachment.State }}
  {%- if attachment.Reason %}
  # Reason: {{ attachment.Reason }}
  {%- endif %}
  {%- if attachment.Description %}
  # Description: {{ attachment.Description }}
  {%- endif %}
}
{% endfor %}