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

[Bug] ddos_protection_plan can only be configured for all workspaces #33

Open
matthiss opened this issue Nov 17, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@matthiss
Copy link

Description

The ddos_protection_plan can only be configured for all workspaces at once. If it's only enabled in workspace a, the module fails if it is run in workspace b.

  virtual_network = {
    environment = {
      name                = format(local.resource_name.virtual_network, terraform.workspace)
      location            = local.location
      resource_group_name = data.azurerm_resource_group.environment.name
      address_space       = [format("%s/%s", local.network.address_space[terraform.workspace], local.network.netmask.default)]
      tags                = local.tags
      ddos_protection_plan = terraform.workspace != "prod" ? {} : {
        enable  = true
        id      = "/subscriptions/1234/resourceGroups/example-com-rg/providers/Microsoft.Network/ddosProtectionPlans/example-com-ddos-protection"
      }
    }
  }

If terraform plan is executed from test workspace, not from prod, the following error occurs:

│ Error: Missing map element
│ 
│   on .terraform/modules/network/main.tf line 26, in resource "azurerm_virtual_network" "virtual_network":
│   26:       id     = local.virtual_network[each.key].ddos_protection_plan.id
│     ├────────────────
│     │ each.key is "environment"
│     │ local.virtual_network is object with 1 attribute "environment"
│ 
│ This map does not have an element with the key "id".

Reproduction steps

restrict ddos_protection_plan to one workspace, then plan/apply from another workspace

Current Behavior

Error: missing map element

Expected Behavior

ddos_protection_plan is ignored/skipped in unwanted environments/workspaces

Additional information

No response

@matthiss matthiss added the bug Something isn't working label Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant