Azure / terraform-azurerm-avm-res-web-site

MIT License
17 stars 10 forks source link

[AVM Question/Feedback]: auth_settings_v2 block errors #69

Closed vaiddas closed 5 months ago

vaiddas commented 6 months ago

Check for previous/existing GitHub issues

Description

We are using Azure/avm-res-web-site/azurerm module and one of our requirement is to have authentication setup in the app service plan.

Under auth_settings_v2 block, we are just specifying active_directory_v2 but running terraform plan throws below error.

Aren't these all values optional?

Can you please provide some examples here how we can pass the inputs to auth_settings_v2 then?

Thanks.

`│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 823, in resource "azurerm_linux_web_app" "this":
│  823:         for_each = auth_settings_v2.value.apple_v2
│     ├────────────────
│     │ auth_settings_v2.value.apple_v2 is null
│
│ Cannot use a null value in for_each.
╵
╷
│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 832, in resource "azurerm_linux_web_app" "this":
│  832:         for_each = auth_settings_v2.value.azure_static_web_app_v2
│     ├────────────────
│     │ auth_settings_v2.value.azure_static_web_app_v2 is null
│
│ Cannot use a null value in for_each.
╵
╷
│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 839, in resource "azurerm_linux_web_app" "this":
│  839:         for_each = auth_settings_v2.value.custom_oidc_v2
│     ├────────────────
│     │ auth_settings_v2.value.custom_oidc_v2 is null
│
│ Cannot use a null value in for_each.
╵
╷
│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 857, in resource "azurerm_linux_web_app" "this":
│  857:         for_each = auth_settings_v2.value.facebook_v2
│     ├────────────────
│     │ auth_settings_v2.value.facebook_v2 is null
│
│ Cannot use a null value in for_each.
╵
╷
│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 868, in resource "azurerm_linux_web_app" "this":
│  868:         for_each = auth_settings_v2.value.github_v2
│     ├────────────────
│     │ auth_settings_v2.value.github_v2 is null
│
│ Cannot use a null value in for_each.
╵
╷
│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 877, in resource "azurerm_linux_web_app" "this":
│  877:         for_each = auth_settings_v2.value.google_v2
│     ├────────────────
│     │ auth_settings_v2.value.google_v2 is null
│
│ Cannot use a null value in for_each.
╵
╷
│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 888, in resource "azurerm_linux_web_app" "this":
│  888:         for_each = auth_settings_v2.value.microsoft_v2
│     ├────────────────
│     │ auth_settings_v2.value.microsoft_v2 is null
│
│ Cannot use a null value in for_each.
╵
╷
│ Error: Invalid dynamic for_each value
│
│   on .terraform\modules\test\main.web_app.tf line 898, in resource "azurerm_linux_web_app" "this":
│  898:         for_each = auth_settings_v2.value.twitter_v2
│     ├────────────────
│     │ auth_settings_v2.value.twitter_v2 is null
│
│ Cannot use a null value in for_each.
`╵``
vaiddas commented 6 months ago

Just to update my auth_settings_v2 block is something like below:

  auth_settings_v2 = {
        auth_settings_v2 = {
          auth_enabled = true
          default_provider = "AzureActiveDirectory"
          require_authentication = true
          require_https = true
          unauthenticated_action = "RedirectToLoginPage"

        active_directory_v2 = {
            active_directory_v2 = {
              allowed_applications = ["xxxxxxxx"]
              client_id = "xxxxxxx"
              client_secret_setting_name = "xxxxxxx"
              tenant_auth_endpoint  = "xxxxxxx"
                }
            }
        login = {
            login1 = {
              token_store_enabled = true
              validate_nonce = true
            }
        }
      }
    }
donovm4 commented 6 months ago

Hi @vaiddas - currently looking into this.

donovm4 commented 5 months ago

addressed in v0.6.0 release