Skip to content

cyber-scot/terraform-azurerm-logic-app

Repository files navigation

resource "azurerm_service_plan" "service_plan" {
  for_each                     = { for app in var.logic_apps : app.name => app if app.app_service_plan_name != null }
  name                         = each.value.app_service_plan_name != null ? each.value.app_service_plan_name : "asp-${each.value.name}"
  resource_group_name          = var.rg_name
  location                     = var.location
  os_type                      = each.value.os_type != null ? each.value.os_type : "Linux"
  sku_name                     = each.value.sku_name
  app_service_environment_id   = each.value.app_service_environment_id != null ? each.value.app_service_environment_id : null
  maximum_elastic_worker_count = each.value.maximum_elastic_worker_count != null ? each.value.maximum_elastic_worker_count : null
  worker_count                 = each.value.worker_count != null ? each.value.worker_count : null
  zone_balancing_enabled       = each.value.zone_balancing_enabled != null ? each.value.zone_balancing_enabled : null
  tags                         = var.tags
}

resource "azurerm_logic_app_standard" "logic_app" {
  depends_on = [azurerm_service_plan.service_plan]
  for_each   = { for app in var.logic_apps : app.name => app if app.app_service_plan_name != null }

  name                       = each.value.name
  location                   = var.location
  resource_group_name        = var.rg_name
  tags                       = var.tags
  app_service_plan_id        = azurerm_service_plan.service_plan[each.key].id
  storage_account_name       = each.value.storage_account_name
  storage_account_access_key = each.value.storage_account_access_key
  use_extension_bundle       = each.value.use_extension_bundle != null ? each.value.use_extension_bundle : null
  bundle_version             = each.value.use_extension_bundle != null ? each.value.bundle_version : null
  client_affinity_enabled    = each.value.client_affinity_enabled != null ? each.value.client_affinity_enabled : null
  client_certificate_mode    = each.value.client_certificate_mode != null ? each.value.client_certificate_mode : null
  enabled                    = each.value.enabled != null ? each.value.enabled : true
  https_only                 = each.value.https_only != null ? each.value.https_only : true
  version                    = each.value.version != null ? each.value.version : null
  virtual_network_subnet_id  = each.value.virtual_network_subnet_id != null ? each.value.virtual_network_subnet_id : null
  app_settings               = each.value.app_settings != null ? each.value.app_settings : null

  dynamic "connection_string" {
    for_each = each.value.connection_string != null ? [each.value.connection_string] : []
    content {
      name  = connection_string.value.name
      type  = connection_string.value.type
      value = connection_string.value.value
    }
  }

  dynamic "site_config" {
    for_each = each.value.site_config != null ? [each.value.site_config] : []
    content {
      always_on                 = site_config.value.always_on != null ? site_config.value.always_on : null
      app_scale_limit           = site_config.value.app_scale_limit != null ? site_config.value.app_scale_limit : null
      elastic_instance_minimum  = site_config.value.elastic_instance_minimum != null ? site_config.value.elastic_instance_minimum : null
      ftps_state                = site_config.value.ftps_state != null ? site_config.value.ftps_state : null
      health_check_path         = site_config.value.health_check_path != null ? site_config.value.health_check_path : null
      http2_enabled             = site_config.value.http2_enabled != null ? site_config.value.http2_enabled : null
      min_tls_version           = site_config.value.min_tls_version != null ? site_config.value.min_tls_version : null
      dotnet_framework_version  = site_config.value.dotnet_framework_version != null ? site_config.value.dotnet_framework_version : null
      scm_type                  = site_config.value.scm_type != null ? site_config.value.scm_type : null
      use_32_bit_worker_process = site_config.value.use_32_bit_worker_process != null ? site_config.value.use_32_bit_worker_process : null
      #      websockets_enabled        = site_config.value.websockets_enabled != null ? site_config.value.websockets_enabled : null

      ip_restriction = [for ipr in site_config.value.ip_restriction : {
        name                      = ipr.name
        ip_address                = ipr.ip_address
        virtual_network_subnet_id = ipr.virtual_network_subnet_id
        priority                  = ipr.priority
        action                    = ipr.action
        headers = [for hdr in ipr.headers : {
          x_azure_fdid      = hdr.x_azure_fdid
          x_fd_health_probe = hdr.x_fd_health_probe
          x_forwarded_for   = hdr.x_forwarded_for
          x_forwarded_host  = hdr.x_forwarded_host
        }]
      }]

      scm_ip_restriction = [for scmr in site_config.value.scm_ip_restriction : {
        name                      = scmr.name
        ip_address                = scmr.ip_address
        virtual_network_subnet_id = scmr.virtual_network_subnet_id
        priority                  = scmr.priority
        action                    = scmr.action
        headers = [for hdr in scmr.headers : {
          x_azure_fdid      = hdr.x_azure_fdid
          x_fd_health_probe = hdr.x_fd_health_probe
          x_forwarded_for   = hdr.x_forwarded_for
          x_forwarded_host  = hdr.x_forwarded_host
        }]
      }]

      dynamic "cors" {
        for_each = site_config.value.cors != null ? [site_config.value.cors] : []
        content {
          allowed_origins     = cors.value.allowed_origins
          support_credentials = cors.value.support_credentials != null ? cors.value.support_credentials : null
        }
      }
    }
  }

  dynamic "identity" {
    for_each = each.value.identity_type == "SystemAssigned" ? [each.value.identity_type] : []
    content {
      type = each.value.identity_type
    }
  }

  dynamic "identity" {
    for_each = each.value.identity_type == "SystemAssigned, UserAssigned" ? [each.value.identity_type] : []
    content {
      type         = each.value.identity_type
      identity_ids = try(each.value.identity_ids, [])
    }
  }


  dynamic "identity" {
    for_each = each.value.identity_type == "UserAssigned" ? [each.value.identity_type] : []
    content {
      type         = each.value.identity_type
      identity_ids = length(try(each.value.identity_ids, [])) > 0 ? each.value.identity_ids : []
    }
  }
}

Requirements

No requirements.

Providers

Name Version
azurerm n/a

Modules

No modules.

Resources

Name Type
azurerm_logic_app_standard.logic_app resource
azurerm_service_plan.service_plan resource

Inputs

Name Description Type Default Required
location The location for this resource to be put in string n/a yes
logic_apps The logic app blocks
list(object({
name = string
app_service_plan_name = optional(string)
os_type = string
sku_name = string
app_service_environment_id = optional(string, null)
maximum_elastic_worker_count = optional(number, null)
worker_count = optional(number, null)
zone_balancing_enabled = optional(bool, null)
storage_account_name = string
storage_account_access_key = optional(string)
use_extension_bundle = optional(bool)
bundle_version = optional(string)
client_affinity_enabled = optional(bool)
client_certificate_mode = optional(string)
enabled = optional(bool)
https_only = optional(bool, true)
version = optional(string)
virtual_network_subnet_id = optional(string)
identity_type = optional(string)
identity_ids = optional(list(string))
app_settings = optional(map(string))

connection_string = optional(object({
name = string
type = string
value = string
}))

site_config = optional(object({
always_on = optional(bool)
app_scale_limit = optional(number)
dotnet_framework_version = optional(string)
elastic_instance_minimum = optional(number)
ftps_state = optional(string)
health_check_path = optional(string)
http2_enabled = optional(bool, false)
scm_use_main_ip_restriction = optional(bool, false)
scm_min_tls_version = optional(string, "1.2")
scm_type = optional(string)
linux_fx_version = optional(string)
min_tls_version = optional(string, "1.2")
pre_warmed_instance_count = optional(number)
public_network_enabled = optional(bool, false)
runtime_scale_monitoring_enabled = optional(bool, false)
use_32_bit_worker_process = optional(bool)
vnet_route_all_enabled = optional(bool)
websocket_enabled = optional(bool)

ip_restriction = optional(list(object({
name = optional(string)
ip_address = optional(string)
service_tag = optional(string)
virtual_network_subnet_id = optional(string)
priority = optional(number)
action = optional(string)
headers = optional(object({
x_azure_fdid = optional(string)
x_fd_health_probe = optional(string)
x_forwarded_for = optional(string)
x_forwarded_host = optional(string)
}))
})), [])

scm_ip_restriction = optional(list(object({
name = optional(string)
ip_address = optional(string)
service_tag = optional(string)
virtual_network_subnet_id = optional(string)
priority = optional(number)
action = optional(string)
headers = optional(object({
x_azure_fdid = optional(string)
x_fd_health_probe = optional(string)
x_forwarded_for = optional(string)
x_forwarded_host = optional(string)
}))
})), [])

cors = optional(object({
allowed_origins = optional(set(string))
support_credentials = optional(bool)
}))
}))
}))
null no
rg_name The name of the resource group, this module does not create a resource group, it is expecting the value of a resource group already exists string n/a yes
tags A map of the tags to use on the resources that are deployed with this module. map(string) n/a yes

Outputs

Name Description
logic_app_custom_domain_verification_ids Custom domain verification IDs for the Logic Apps
logic_app_default_hostnames The default hostnames of the Logic Apps
logic_app_identities Managed Service Identity information for the Logic Apps
logic_app_ids The IDs of the Logic Apps
logic_app_kinds The kinds of the Logic Apps
logic_app_outbound_ip_addresses Comma-separated list of outbound IP addresses for the Logic Apps
logic_app_possible_outbound_ip_addresses Comma-separated list of possible outbound IP addresses for the Logic Apps
logic_app_site_credentials Site-level credentials for publishing to the Logic Apps
logic_app_tenant_ids Tenant IDs for the Service Principal associated with the MSI of the Logic Apps
service_plan_ids The IDs of the service plans
service_plan_kinds The kinds of the service plans
service_plan_names The names of the service plans
service_plan_reserved The reserved property of the service plans

About

A module used to deploy Azure Logic Apps πŸ“ˆ

Resources

License

Stars

Watchers

Forks

Packages

No packages published