{% set config = merged_configs.get('azurerm_service_plan', {}) %}
{% set comments = compliance_comments.get('azurerm_service_plan', []) %}
# ------------------------------------------------------------------------------
# Azure Service Plan
# ------------------------------------------------------------------------------
{% for comment in comments %}
# {{ comment }}
{% endfor %}

resource "azurerm_service_plan" "this" {
  name                = "{{ config.get('name', project_id ~ '-plan') }}"
  resource_group_name = var.resource_group_name
  location            = var.region
  os_type             = "{{ config.get('os_type', 'Linux') }}"
  sku_name            = "{{ config.get('sku_name', 'P1v3') }}"

  {% if config.get('worker_count') %}
  worker_count = {{ config.worker_count }}
  {% endif %}

  {% if config.get('zone_balancing_enabled') %}
  zone_balancing_enabled = {{ config.zone_balancing_enabled | lower }}
  {% endif %}

  tags = {
    Name      = "{{ config.get('name', project_id ~ '-plan') }}"
    ManagedBy = "complyform"
  }
}
