Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malmiller/1664 add logic app module #3

Merged
merged 12 commits into from
Jan 5, 2021
Merged
3 changes: 3 additions & 0 deletions locals.combined_objects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ locals {
combined_objects_resource_groups = merge(map(local.client_config.landingzone_key, module.resource_groups), try(var.remote_objects.resource_groups, {}))
combined_objects_storage_accounts = merge(map(local.client_config.landingzone_key, module.storage_accounts), try(var.remote_objects.storage_accounts, {}))
combined_objects_synapse_workspaces = merge(map(local.client_config.landingzone_key, module.synapse_workspaces), try(var.remote_objects.synapse_workspaces, {}))
combined_objects_logic_app_workflow = merge(map(local.client_config.landingzone_key, module.logic_app_workflow), try(var.remote_objects.logic_app_workflow, {}))
combined_objects_integration_service_environment = merge(map(local.client_config.landingzone_key, module.integration_service_environment), try(var.remote_objects.integration_service_environment, {}))
combined_objects_logic_app_integration_account = merge(map(local.client_config.landingzone_key, module.logic_app_integration_account), try(var.remote_objects.logic_app_integration_account, {}))
}
11 changes: 11 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ locals {
azurerm_application_insights = try(var.webapp.azurerm_application_insights, {})
}

logic_app = {
integration_service_environment = try(var.logic_app.integration_service_environment, {})
logic_app_action_custom = try(var.logic_app.logic_app_action_custom, {})
logic_app_action_http = try(var.logic_app.logic_app_action_http, {})
logic_app_integration_account = try(var.logic_app.logic_app_integration_account, {})
logic_app_trigger_custom = try(var.logic_app.logic_app_trigger_custom, {})
logic_app_trigger_http_request = try(var.logic_app.logic_app_trigger_http_request, {})
logic_app_trigger_recurrence = try(var.logic_app.logic_app_trigger_recurrence, {})
logic_app_workflow = try(var.logic_app.logic_app_workflow, {})
}

shared_services = {
automations = try(var.shared_services.automations, {})
monitoring = try(var.shared_services.monitoring, {})
Expand Down
146 changes: 146 additions & 0 deletions logic_app.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
##### azurerm_integration_service_environment
module "integration_service_environment" {
source = "./modules/logic_app/integration_service_environment"

for_each = local.logic_app.integration_service_environment

name = each.value.name
resource_group_name = module.resource_groups[each.value.resource_group_key].name
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
sku_name = each.value.sku_name
access_endpoint_type = each.value.access_endpoint_type
virtual_network_subnet_ids = each.value.virtual_network_subnet_ids
global_settings = local.global_settings
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
tags = try(each.value.tags, null)
}

output "integration_service_environment" {
value = module.integration_service_environment
}

##### azurerm_logic_app_action_custom
module "logic_app_action_custom" {
source = "./modules/logic_app/action_custom"

for_each = local.logic_app.logic_app_action_custom

name = each.value.name
logic_app_id = try(each.value.lz_key, null) == null ? local.combined_objects_logic_app_workflow[local.client_config.landingzone_key][each.value.logic_app_workflow_key].id : local.combined_objects_logic_app_workflow[each.value.lz_key][each.value.logic_app_workflow_key].id
body = each.value.body
}

output "logic_app_action_custom" {
value = module.logic_app_action_custom
}

##### azurerm_logic_app_action_http
module "logic_app_action_http" {
source = "./modules/logic_app/action_http"

for_each = local.logic_app.logic_app_action_http

name = each.value.name
logic_app_id = try(each.value.lz_key, null) == null ? local.combined_objects_logic_app_workflow[local.client_config.landingzone_key][each.value.logic_app_workflow_key].id : local.combined_objects_logic_app_workflow[each.value.lz_key][each.value.logic_app_workflow_key].id
method = each.value.method
uri = each.value.uri
body = each.value.body
headers = each.value.headers
run_after = each.value.run_after
}

output "logic_app_action_http" {
value = module.logic_app_action_http
}

##### azurerm_logic_app_integration_account
module "logic_app_integration_account" {
source = "./modules/logic_app/integration_account"

for_each = local.logic_app.logic_app_integration_account

name = each.value.name
resource_group_name = module.resource_groups[each.value.resource_group_key].name
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
sku_name = each.value.sku_name
global_settings = local.global_settings
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
tags = try(each.value.tags, null)
}

output "logic_app_integration_account" {
value = module.logic_app_integration_account
}

##### azurerm_logic_app_trigger_custom
module "logic_app_trigger_custom" {
source = "./modules/logic_app/trigger_custom"

for_each = local.logic_app.logic_app_trigger_custom

name = each.value.name
logic_app_id = try(each.value.lz_key, null) == null ? local.combined_objects_logic_app_workflow[local.client_config.landingzone_key][each.value.logic_app_workflow_key].id : local.combined_objects_logic_app_workflow[each.value.lz_key][each.value.logic_app_workflow_key].id
body = each.value.body
}

output "logic_app_trigger_custom" {
value = module.logic_app_trigger_custom
}

##### azurerm_logic_app_trigger_http_request
module "logic_app_trigger_http_request" {
source = "./modules/logic_app/trigger_http_request"

for_each = local.logic_app.logic_app_trigger_http_request

name = each.value.name
logic_app_id = try(each.value.lz_key, null) == null ? local.combined_objects_logic_app_workflow[local.client_config.landingzone_key][each.value.logic_app_workflow_key].id : local.combined_objects_logic_app_workflow[each.value.lz_key][each.value.logic_app_workflow_key].id
schema = each.value.schema
method = each.value.method
relative_path = each.value.relative_path
}

output "logic_app_trigger_http_request" {
value = module.logic_app_trigger_http_request
}

##### azurerm_logic_app_trigger_recurrence
module "logic_app_trigger_recurrence" {
source = "./modules/logic_app/trigger_recurrence"

for_each = local.logic_app.logic_app_trigger_recurrence

name = each.value.name
logic_app_id = try(each.value.lz_key, null) == null ? local.combined_objects_logic_app_workflow[local.client_config.landingzone_key][each.value.logic_app_workflow_key].id : local.combined_objects_logic_app_workflow[each.value.lz_key][each.value.logic_app_workflow_key].id
frequency = each.value.frequency
interval = each.value.interval
start_time = each.value.start_time
# time_zone = try(each.value.time_zone, null)
}

output "logic_app_trigger_recurrence" {
value = module.logic_app_trigger_recurrence
}

##### azurerm_logic_app_workflow
module "logic_app_workflow" {
source = "./modules/logic_app/workflow"

for_each = local.logic_app.logic_app_workflow

name = each.value.name
resource_group_name = module.resource_groups[each.value.resource_group_key].name
location = lookup(each.value, "region", null) == null ? module.resource_groups[each.value.resource_group_key].location : local.global_settings.regions[each.value.region]
integration_service_environment_id = try(each.value.integration_service_environment_key, null) != null ? try(each.value.lz_key, null) == null ? local.combined_objects_integration_service_environment[local.client_config.landingzone_key][each.value.integration_service_environment_key].id : local.combined_objects_integration_service_environment[each.value.lz_key][each.value.integration_service_environment_key].id : null
logic_app_integration_account_id = try(each.value.logic_app_integration_account_key, null) != null ? try(each.value.lz_key, null) == null ? local.combined_objects_logic_app_integration_account[local.client_config.landingzone_key][each.value.logic_app_integration_account_key].id : local.combined_objects_logic_app_integration_account[each.value.lz_key][each.value.logic_app_integration_account_key].id : null
workflow_schema = try(each.value.workflow_schema, null)
workflow_version = try(each.value.workflow_version, null)
parameters = try(each.value.parameters, null)
global_settings = local.global_settings
base_tags = try(local.global_settings.inherit_tags, false) ? module.resource_groups[each.value.resource_group_key].tags : {}
tags = try(each.value.tags, null)
}

output "logic_app_workflow" {
value = module.logic_app_workflow
}
8 changes: 8 additions & 0 deletions modules/logic_app/action_custom/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
azurecaf = {
source = "aztfmod/azurecaf"
}
}
required_version = ">= 0.13"
}
5 changes: 5 additions & 0 deletions modules/logic_app/action_custom/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "azurerm_logic_app_action_custom" "action" {
name = var.name
logic_app_id = var.logic_app_id
body = var.body
}
4 changes: 4 additions & 0 deletions modules/logic_app/action_custom/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output id {
value = azurerm_logic_app_action_custom.action.id
description = "The ID of the HTTP Action within the Logic App Workflow"
}
11 changes: 11 additions & 0 deletions modules/logic_app/action_custom/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable name {
description = "(Required) Specifies the name of the HTTP Action to be created within the Logic App Workflow"
}

variable logic_app_id {
description = "(Required) Specifies the ID of the Logic App Workflow"
}

variable body {
description = "(Required) Specifies the JSON Blob defining the Body of this Custom Action"
}
8 changes: 8 additions & 0 deletions modules/logic_app/action_http/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
azurecaf = {
source = "aztfmod/azurecaf"
}
}
required_version = ">= 0.13"
}
17 changes: 17 additions & 0 deletions modules/logic_app/action_http/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "azurerm_logic_app_action_http" "action" {
name = var.name
logic_app_id = var.logic_app_id
method = var.method
uri = var.uri
body = try(var.body, null)
headers = try(var.headers, null)

dynamic "run_after" {
for_each = try(var.run_after, null) != null ? [1] : []

content {
action_name = var.run_after.action_name
action_result = var.run_after.action_result
}
}
}
4 changes: 4 additions & 0 deletions modules/logic_app/action_http/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output id {
value = azurerm_logic_app_action_http.action.id
description = "The ID of the HTTP Action within the Logic App Workflow"
}
27 changes: 27 additions & 0 deletions modules/logic_app/action_http/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
variable name {
description = "(Required) Specifies the name of the HTTP Action to be created within the Logic App Workflow"
}

variable logic_app_id {
description = "(Required) Specifies the ID of the Logic App Workflow"
}

variable method {
description = "(Required) Specifies the HTTP Method which should be used for this HTTP Action"
}

variable uri {
description = "(Required) Specifies the URI which will be called when this HTTP Action is triggered"
}

variable body {
description = "(Optional) Specifies the HTTP Body that should be sent to the uri when this HTTP Action is triggered"
}

variable headers {
description = "(Optional) Specifies a Map of Key-Value Pairs that should be sent to the uri when this HTTP Action is triggered"
}

variable run_after {
description = "(Optional) Specifies the place of the HTTP Action in the Logic App Workflow"
}
8 changes: 8 additions & 0 deletions modules/logic_app/integration_account/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
azurecaf = {
source = "aztfmod/azurecaf"
}
}
required_version = ">= 0.13"
}
18 changes: 18 additions & 0 deletions modules/logic_app/integration_account/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "azurecaf_name" "integration_account" {
name = var.name
resource_type = "azurerm_logic_app_integration_account"
prefixes = [var.global_settings.prefix]
random_length = var.global_settings.random_length
clean_input = true
passthrough = var.global_settings.passthrough
use_slug = var.global_settings.use_slug
}

resource "azurerm_logic_app_integration_account" "ia" {
name = azurecaf_name.integration_account.result
resource_group_name = var.resource_group_name
location = var.location
sku_name = var.sku_name
tags = merge(var.tags, var.base_tags)
}

4 changes: 4 additions & 0 deletions modules/logic_app/integration_account/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output id {
value = azurerm_logic_app_integration_account.ia.id
description = "The ID of the Logic App Integration Account"
}
23 changes: 23 additions & 0 deletions modules/logic_app/integration_account/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
variable name {
description = "(Required) The name which should be used for this Logic App Integration Account"
}

variable resource_group_name {
description = "(Required) The name of the Resource Group where the Logic App Integration Account should exist"
}

variable location {
description = "(Required) The Azure Region where the Logic App Integration Account should exist"
}

variable sku_name {
description = "(Required) The sku name of the Logic App Integration Account. Possible Values are Basic, Free and Standard"
}

variable tags {
description = "(Optional) A mapping of tags which should be assigned to the Logic App Integration Account"
}

variable global_settings {}

variable base_tags {}
8 changes: 8 additions & 0 deletions modules/logic_app/integration_service_environment/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
azurecaf = {
source = "aztfmod/azurecaf"
}
}
required_version = ">= 0.13"
}
20 changes: 20 additions & 0 deletions modules/logic_app/integration_service_environment/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "azurecaf_name" "integration_service_environment" {
name = var.name
resource_type = "azurerm_integration_service_environment"
prefixes = [var.global_settings.prefix]
random_length = var.global_settings.random_length
clean_input = true
passthrough = var.global_settings.passthrough
use_slug = var.global_settings.use_slug
}

resource "azurerm_integration_service_environment" "ise" {
name = azurecaf_name.integration_service_environment.result
resource_group_name = var.resource_group_name
location = var.location
sku_name = var.sku_name
access_endpoint_type = var.access_endpoint_type
virtual_network_subnet_ids = var.virtual_network_subnet_ids
tags = merge(var.tags, var.base_tags)
}

24 changes: 24 additions & 0 deletions modules/logic_app/integration_service_environment/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
output id {
value = azurerm_integration_service_environment.ise.id
description = "The ID of the Integration Service Environment."
}

output connector_endpoint_ip_addresses {
value = azurerm_integration_service_environment.ise.connector_endpoint_ip_addresses
description = "The list of access endpoint ip addresses of connector."
}

output connector_outbound_ip_addresses {
value = azurerm_integration_service_environment.ise.connector_outbound_ip_addresses
description = "The list of outgoing ip addresses of connector."
}

output workflow_endpoint_ip_addresses {
value = azurerm_integration_service_environment.ise.workflow_endpoint_ip_addresses
description = "The list of access endpoint ip addresses of workflow."
}

output workflow_outbound_ip_addresses {
value = azurerm_integration_service_environment.ise.workflow_outbound_ip_addresses
description = "The list of outgoing ip addresses of workflow."
}
Loading