Skip to content

Commit

Permalink
Fix workload profile setting
Browse files Browse the repository at this point in the history
  • Loading branch information
alefteris committed Sep 26, 2024
1 parent 728d68f commit 3320128
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .terraform-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

formatter: "markdown document" # this is required

version: "~> 0.17.0"
version: "~> 0.18.0"

header-from: "_header.md"
footer-from: "_footer.md"
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The following requirements are needed by this module:

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.71)

- <a name="requirement_modtm"></a> [modtm](#requirement\_modtm) (~> 0.3)

- <a name="requirement_random"></a> [random](#requirement\_random) (~> 3.5)

## Providers
Expand All @@ -26,6 +28,8 @@ The following providers are used by this module:

- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (~> 3.71)

- <a name="provider_modtm"></a> [modtm](#provider\_modtm) (~> 0.3)

- <a name="provider_random"></a> [random](#provider\_random) (~> 3.5)

## Resources
Expand All @@ -37,10 +41,12 @@ The following resources are used by this module:
- [azapi_resource.this_environment](https://registry.terraform.io/providers/Azure/azapi/latest/docs/resources/resource) (resource)
- [azurerm_management_lock.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource)
- [azurerm_monitor_diagnostic_setting.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) (resource)
- [azurerm_resource_group_template_deployment.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group_template_deployment) (resource)
- [azurerm_role_assignment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
- [random_id.telem](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) (resource)
- [modtm_telemetry.telemetry](https://registry.terraform.io/providers/Azure/modtm/latest/docs/resources/telemetry) (resource)
- [random_uuid.telemetry](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid) (resource)
- [azurerm_client_config.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source)
- [azurerm_resource_group.parent](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) (data source)
- [modtm_module_source.telemetry](https://registry.terraform.io/providers/Azure/modtm/latest/docs/data-sources/module_source) (data source)

<!-- markdownlint-disable MD013 -->
## Required Inputs
Expand Down
2 changes: 1 addition & 1 deletion examples/.terraform-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

formatter: "markdown document" # this is required

version: "~> 0.17.0"
version: "~> 0.18.0"

header-from: "_header.md"
footer-from: "_footer.md"
Expand Down
17 changes: 5 additions & 12 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ locals {
share_name = sv.body.properties.azureFile.shareName
}
}
# these workload_profile_* locals are used to mimic the behaviour of the azurerm provider
workload_profile_consumption_enabled = contains([
for wp in var.workload_profile :
wp.name == "Consumption" && wp.workload_profile_type == "Consumption"
], true)
workload_profile_outputs = azapi_resource.this_environment.body.properties.workloadProfiles != null ? [
for wp in azapi_resource.this_environment.body.properties.workloadProfiles : merge(
{
Expand All @@ -50,16 +55,4 @@ locals {
} : {}
)
] : null
workload_profiles = setsubtract(var.workload_profile, [{
name = "Consumption"
workloadProfileType = "Consumption"
}])
# these workload_profile_* locals are used to mimic the behaviour of the azurerm provider
workload_profiles_consumption_enabled = contains(
var.workload_profile,
{
name = "Consumption"
workloadProfileType = "Consumption"
}
)
}
1 change: 1 addition & 0 deletions main.dapr_component.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ resource "azapi_resource" "dapr_components" {

dynamic "timeouts" {
for_each = each.value.timeouts == null ? [] : [each.value.timeouts]

content {
create = timeouts.value.create
delete = timeouts.value.delete
Expand Down
1 change: 1 addition & 0 deletions main.storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ resource "azapi_resource" "storages" {

dynamic "timeouts" {
for_each = each.value.timeouts == null ? [] : [each.value.timeouts]

content {
create = timeouts.value.create
delete = timeouts.value.delete
Expand Down
3 changes: 2 additions & 1 deletion main.telemetry.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ data "azurerm_client_config" "telemetry" {
}

data "modtm_module_source" "telemetry" {
count = var.enable_telemetry ? 1 : 0
count = var.enable_telemetry ? 1 : 0

module_path = path.module
}

Expand Down
15 changes: 13 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ resource "azapi_resource" "this_environment" {
"internal" = var.internal_load_balancer_enabled
"infrastructureSubnetId" = var.infrastructure_subnet_id
} : null
workloadProfiles = local.workload_profiles_consumption_enabled ? setunion([
workloadProfiles = local.workload_profile_consumption_enabled ? setunion([
{
name = "Consumption"
workloadProfileType = "Consumption"
}],
local.workload_profiles
[for wp in var.workload_profile :
{
name = wp.name
workloadProfileType = wp.workload_profile_type
minimumCount = wp.minimum_count
maximumCount = wp.maximum_count
} if wp.workload_profile_type != "Consumption"
]
) : null
zoneRedundant = var.zone_redundancy_enabled
}
Expand All @@ -56,6 +63,7 @@ resource "azapi_resource" "this_environment" {

dynamic "timeouts" {
for_each = var.timeouts == null ? [] : [var.timeouts]

content {
create = timeouts.value.create
delete = timeouts.value.delete
Expand Down Expand Up @@ -100,18 +108,21 @@ resource "azurerm_monitor_diagnostic_setting" "this" {
dynamic "enabled_log" {
for_each = each.value.log_categories

content {
category = enabled_log.value
}
}
dynamic "enabled_log" {
for_each = each.value.log_groups

content {
category_group = enabled_log.value
}
}
dynamic "metric" {
for_each = each.value.metric_categories

content {
category = metric.value
}
Expand Down
4 changes: 4 additions & 0 deletions terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ terraform {
source = "hashicorp/azurerm"
version = "~> 3.71"
}
modtm = {
source = "Azure/modtm"
version = "~> 0.3"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
Expand Down

0 comments on commit 3320128

Please sign in to comment.