# Internet Gateway: {{ resource.original_name }}
resource "aws_internet_gateway" "{{ resource.terraform_name }}" {
{% if resource.config.vpc_id is tf_ref %}
  vpc_id = {{ resource.config.vpc_id }}
{% else %}
{% set vpc_resource = graph.get_resource(resource.config.vpc_id) %}
{% if vpc_resource and vpc_resource.terraform_name %}
  vpc_id = aws_vpc.{{ vpc_resource.terraform_name }}.id
{% else %}
  # WARNING: VPC {{ resource.config.vpc_id }} not found in graph - using original ID
  vpc_id = "{{ resource.config.vpc_id }}"
{% endif %}
{% endif %}

  tags = {
    Name        = "{{ resource.original_name }}"
    Environment = var.environment
    ManagedBy   = "replimap"
    SourceId    = "{{ resource.id }}"
{% for key, value in resource.tags.items() if key != 'Name' %}
    {{ key | quote_key }} = {{ value | quote }}
{% endfor %}
  }
}
