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

cnspec integrate azure - ignore non-enabled subscriptions #1560

Open
AdamVB opened this issue Jan 29, 2025 · 0 comments
Open

cnspec integrate azure - ignore non-enabled subscriptions #1560

AdamVB opened this issue Jan 29, 2025 · 0 comments

Comments

@AdamVB
Copy link
Contributor

AdamVB commented Jan 29, 2025

Describe the bug
When deploying to a tenant with a disabled subscription we run run into an error:

Image

Proposed fix
We still collect all subs with the azurerm data source, but filter it and use that going forward.

data "azurerm_subscriptions" "available" {}

# Filter only active subscriptions
locals {
  active_subscriptions = [
    for sub in data.azurerm_subscriptions.available.subscriptions :
    sub if sub.state == "Enabled"
  ]
}

resource "azurerm_role_assignment" "reader" {
  count                = length(local.active_subscriptions)
  principal_id         = azuread_service_principal.mondoo.object_id
  role_definition_name = "Reader"
  scope                = local.active_subscriptions[count.index].id
}

Another thing that might be worth discussing: Should the allow/deny list affect where we deploy the role assignment? Currently the allow or deny list is only used for the mondoo integration itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant