{% extends "common/base_resource.tf.j2" %}
{% block resources %}
{% for resource in resources %}
{{ resource_spacer() }}
resource "azurerm_public_ip" "{{ resource.name.replace('-', '_').replace('.', '_').lower() }}" {
  name                = "{{ resource.properties.name }}"
  location            = "{{ resource.properties.location }}"
  resource_group_name = "{{ resource.properties.resource_group_name }}"
  allocation_method   = "{{ resource.properties.allocation_method }}"
  
  {% if resource.properties.sku is defined %}
  sku = "{{ resource.properties.sku }}"
  {% endif %}
  
  {% if resource.properties.sku_tier is defined %}
  sku_tier = "{{ resource.properties.sku_tier }}"
  {% endif %}
  
  {% if resource.properties.zones is defined and resource.properties.zones %}
  zones = {{ resource.properties.zones | tojson }}
  {% endif %}
  
  {% if resource.properties.domain_name_label is defined and resource.properties.domain_name_label %}
  domain_name_label = "{{ resource.properties.domain_name_label }}"
  {% endif %}
  
  {% if resource.properties.edge_zone is defined and resource.properties.edge_zone %}
  edge_zone = "{{ resource.properties.edge_zone }}"
  {% endif %}
  
  {% if resource.properties.idle_timeout_in_minutes is defined %}
  idle_timeout_in_minutes = {{ resource.properties.idle_timeout_in_minutes }}
  {% endif %}
  
  {% if resource.properties.ip_version is defined %}
  ip_version = "{{ resource.properties.ip_version }}"
  {% endif %}
  
  {% if resource.properties.public_ip_prefix_id is defined and resource.properties.public_ip_prefix_id %}
  public_ip_prefix_id = "{{ resource.properties.public_ip_prefix_id }}"
  {% endif %}
  
  {% if resource.properties.reverse_fqdn is defined and resource.properties.reverse_fqdn %}
  reverse_fqdn = "{{ resource.properties.reverse_fqdn }}"
  {% endif %}
  
  {% set tags_value = resource.properties.tags if resource.properties.tags else {} %}
  tags = {{ tags_value | tojson }}
}

{% endfor %}
{% endblock %}
