# ElastiCache Subnet Group: {{ resource.original_name }}
resource "aws_elasticache_subnet_group" "{{ resource.terraform_name }}" {
  name        = "{{ resource.config.name }}"
  description = "{{ resource.config.description | default('Managed by RepliMap') }}"

  subnet_ids = [
{% for subnet_id in resource.config.subnet_ids %}
{% if subnet_id is tf_ref %}
    {{ subnet_id }},
{% else %}
{% set subnet_resource = graph.get_resource(subnet_id) %}
{% if subnet_resource and subnet_resource.terraform_name %}
    aws_subnet.{{ subnet_resource.terraform_name }}.id,
{% else %}
    "{{ subnet_id }}",
{% endif %}
{% endif %}
{% endfor %}
  ]

  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 %}
  }
}
