Skip to content

Commit

Permalink
additional outputs added for function app slots (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
donovm4 authored Jul 24, 2024
1 parent 4dd51aa commit 87d6c6b
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 6 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2021,14 +2021,30 @@ Description: The application insights resource.

Description: The locks of the deployment slots.

### <a name="output_function_app_active_slot"></a> [function\_app\_active\_slot](#output\_function\_app\_active\_slot)

Description: The active slot.

### <a name="output_function_app_deployment_slots"></a> [function\_app\_deployment\_slots](#output\_function\_app\_deployment\_slots)

Description: The deployment slots.

### <a name="output_identity_principal_id"></a> [identity\_principal\_id](#output\_identity\_principal\_id)

Description: The object principal id of the resource.

### <a name="output_kind"></a> [kind](#output\_kind)

Description: n/a

### <a name="output_name"></a> [name](#output\_name)

Description: The name of the resource.

### <a name="output_os_type"></a> [os\_type](#output\_os\_type)

Description: n/a

### <a name="output_private_endpoint_locks"></a> [private\_endpoint\_locks](#output\_private\_endpoint\_locks)

Description: The locks of the deployment slots.
Expand Down
34 changes: 32 additions & 2 deletions examples/deployment_slot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,39 @@ module "test" {
resource_group_name = azurerm_resource_group.example.name
}
site_config = {
application_stack = {
dotnet = {
dotnet_version = "8.0"
use_custom_runtime = false
use_dotnet_isolated_runtime = true
}
}
}
deployment_slots = {
slot1 = {
name = "staging"
site_config = {
application_stack = {
dotnet = {
dotnet_version = "8.0"
use_custom_runtime = false
use_dotnet_isolated_runtime = true
}
}
}
},
slot2 = {
name = "development"
site_config = {
application_stack = {
dotnet = {
dotnet_version = "8.0"
use_custom_runtime = false
use_dotnet_isolated_runtime = true
}
}
}
}
}
Expand Down Expand Up @@ -201,10 +223,18 @@ Description: ID of active slot

Description: Full output of deployment slots created

### <a name="output_kind"></a> [kind](#output\_kind)

Description: n/a

### <a name="output_name"></a> [name](#output\_name)

Description: This is the full output for the resource.

### <a name="output_os_type"></a> [os\_type](#output\_os\_type)

Description: n/a

### <a name="output_resource"></a> [resource](#output\_resource)

Description: This is the full output for the resource.
Expand Down
26 changes: 24 additions & 2 deletions examples/deployment_slot/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,39 @@ module "test" {
resource_group_name = azurerm_resource_group.example.name
}

site_config = {
application_stack = {
dotnet = {
dotnet_version = "8.0"
use_custom_runtime = false
use_dotnet_isolated_runtime = true
}
}
}

deployment_slots = {
slot1 = {
name = "staging"
site_config = {

application_stack = {
dotnet = {
dotnet_version = "8.0"
use_custom_runtime = false
use_dotnet_isolated_runtime = true
}
}
}
},
slot2 = {
name = "development"
site_config = {

application_stack = {
dotnet = {
dotnet_version = "8.0"
use_custom_runtime = false
use_dotnet_isolated_runtime = true
}
}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions examples/deployment_slot/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
output "active_slot" {
description = "ID of active slot"
value = module.test.web_app_active_slot
value = module.test.kind == "functionapp" ? module.test.function_app_active_slot : module.test.web_app_active_slot
}

output "deployment_slots" {
description = "Full output of deployment slots created"
sensitive = true
value = module.test.web_app_deployment_slots
value = module.test.function_app_deployment_slots
}

output "kind" {
value = module.test.kind
}

output "name" {
description = "This is the full output for the resource."
value = module.test.name
}

output "os_type" {
value = module.test.os_type
}

output "resource" {
description = "This is the full output for the resource."
sensitive = true
Expand Down
18 changes: 18 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,35 @@ output "deployment_slot_locks" {
value = azurerm_management_lock.slot != null ? azurerm_management_lock.slot : null
}

output "function_app_active_slot" {
description = "The active slot."
value = var.kind == "functionapp" && var.app_service_active_slot != null ? azurerm_function_app_active_slot.this[0].id : (var.kind == "functionapp" && var.app_service_active_slot == null && var.os_type == "Windows") ? azurerm_windows_function_app.this[0].id : var.kind == "functionapp" && var.app_service_active_slot == null && var.os_type == "Linux" ? azurerm_linux_function_app.this[0].id : null
}

output "function_app_deployment_slots" {
description = "The deployment slots."
value = var.kind == "functionapp" && var.os_type == "Windows" && var.deployment_slots != null ? azurerm_windows_function_app_slot.this : azurerm_linux_function_app_slot.this
}

output "identity_principal_id" {
description = "The object principal id of the resource."
sensitive = true
value = var.kind == "functionapp" ? (var.os_type == "Windows" ? (length(azurerm_windows_function_app.this[0].identity) > 0 ? azurerm_windows_function_app.this[0].identity[0].principal_id : null) : length(azurerm_linux_function_app.this[0].identity) > 0 ? azurerm_linux_function_app.this[0].identity[0].principal_id : null) : (var.os_type == "Windows" ? (length(azurerm_windows_web_app.this[0].identity) > 0 ? azurerm_windows_web_app.this[0].identity[0].principal_id : null) : length(azurerm_linux_web_app.this[0].identity) > 0 ? azurerm_linux_web_app.this[0].identity[0].principal_id : null)
}

output "kind" {
value = var.kind
}

output "name" {
description = "The name of the resource."
value = (var.kind == "functionapp" || var.kind == "webapp") ? (var.kind == "functionapp" ? (var.os_type == "Windows" ? azurerm_windows_function_app.this[0].name : azurerm_linux_function_app.this[0].name) : (var.os_type == "Windows" ? azurerm_windows_web_app.this[0].name : azurerm_linux_web_app.this[0].name)) : null
}

output "os_type" {
value = var.os_type
}

output "private_endpoint_locks" {
description = "The locks of the deployment slots."
value = azurerm_management_lock.pe != null ? azurerm_management_lock.pe : null
Expand Down

0 comments on commit 87d6c6b

Please sign in to comment.