{# Enhanced Base Resource Template - V2 #}
{# 
   This is the new standardized base template for all Terraform resources.
   It provides a consistent structure and reduces duplication across providers.
   
   Usage:
   {% extends "common/base_resource_v2.tf.j2" %}
   {% set provider = "aws" %}
   {% set resource_type = "aws_instance" %}
   
   Required blocks to override:
   - resources: The main resources block containing the for loop
   
   Optional blocks to override:
   - locals: Local values specific to this resource type
   - variables: Variable definitions
   - outputs: Output definitions
#}

{% import "common/advanced_macros.j2" as macros %}
{# Joiner for consistent blank lines between rendered resources #}
{% set resource_spacer = joiner('\n\n') %}

{# Provider-specific macro imports #}
{% if provider == "aws" %}
  {% import "aws/macros.j2" as provider_macros %}
{% elif provider == "azure" %}
  {% import "azure/macros.j2" as provider_macros %}
{% elif provider == "gcp" %}
  {% import "gcp/macros.j2" as provider_macros %}
{% endif %}

{# ========== Header Documentation ========== #}
{% block header %}
# Terraform configuration for {{ resource_type | default('resources') }}
# Generated by Terraback
# Provider: {{ provider | default('unknown') | upper }}
{% endblock %}

{# ========== Locals Block ========== #}
{% block locals %}
{# Override this block to add local values #}
{% endblock %}

{# ========== Variables Block ========== #}
{% block variables %}
{# Override this block to add variables #}
{% endblock %}

{# ========== Main Resources Block ========== #}
{# Child templates MUST override this block and include their own for loop #}
{% block resources %}
{# Default implementation showing the expected pattern #}
{% for resource in resources %}
  # ERROR: resources block not implemented for {{ resource_type }}
  # Child template should override this block with proper resource definitions
{% endfor %}
{% endblock %}

{# ========== Outputs Block ========== #}
{% block outputs %}
{# Override this block to add outputs #}
{% endblock %}

{# ========== Footer ========== #}
{% block footer %}

# End of {{ resource_type | default('resources') }} configuration
{% endblock %}
