# Network Interfaces (ENIs)
# Generated by Terraback

{% for resource in resources %}
resource "aws_network_interfaces" "{{ resource.name }}" {
  subnets_id         = "{{ resource.subnets_id }}"
{%- if resource.private_ip %}
  private_ip        = "{{ resource.private_ip }}"
{%- endif %}
{%- if resource.private_ips|length > 1 %}
  private_ips       = [
{%- for ip in resource.private_ips %}
    "{{ ip }}"{{ "," if not loop.last }}
{%- endfor %}
  ]
{%- endif %}
{%- if resource.security_groups %}
  security_groups   = [
{%- for sg in resource.security_groups %}
    "{{ sg }}"{{ "," if not loop.last }}
{%- endfor %}
  ]
{%- endif %}
  source_dest_check = {{ 'true' if resource.source_dest_check else 'false' }}
{%- if resource.description %}
  description       = "{{ resource.description }}"
{%- endif %}
{%- if resource.tags %}

  tags = {
{%- for key, value in resource.tags.items() %}
    "{{ key }}" = "{{ value }}"
{%- endfor %}
  }
{%- endif %}
}

{%- if resource.attached and resource.instance_id %}

# Network interface attachment
resource "aws_network_interfaces_attachment" "{{ resource.name }}_attachment" {
  instance_id          = "{{ resource.instance_id }}"
  network_interfaces_id = aws_network_interfaces.{{ resource.name }}.id
  device_index         = {{ resource.device_index }}
}
{%- endif %}
{% if not loop.last %}

{% endif %}
{%- endfor %}