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

Disabling default policies not working #43

Open
scottford-io opened this issue Feb 13, 2024 · 1 comment
Open

Disabling default policies not working #43

scottford-io opened this issue Feb 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@scottford-io
Copy link

scottford-io commented Feb 13, 2024

Describe the bug
New spaces come with a default set of policies enabled. I am trying to change a default policy from "ENABLED" to "DISABLED" with the following code:

resource "mondoo_policy_assignment" "disabled_policies" {
  space_id = mondoo_space.os_policy_testing.id

  policies = [
    "//policy.api.mondoo.app/policies/mondoo-aws-security",
    "//policy.api.mondoo.app/policies/mondoo-azure-security",
    "//policy.api.mondoo.app/policies/mondoo-gcp-security",
  ]

  state = "disabled" # default is enabled, we also support preview and disabled

  depends_on = [
    mondoo_space.os_policy_testing
  ]
}

The code above applies successfully, but after applying, the policies are still enabled:

image

@scottford-io scottford-io added the bug Something isn't working label Feb 13, 2024
@scottford-io scottford-io changed the title Disabling policies not working Disabling default policies not working Feb 13, 2024
@scottford-io
Copy link
Author

@chris-rock after further investigation, I am noticing strange behavior here. It seems that the issue is tide to first runs with the provider, but if I apply another change, then I try to manage a default policy then it works. Here is the full code I am using ...

resource "mondoo_space" "os_policy_testing" {
  name   = "OS policy testing"
  org_id = var.org_id
}

resource "mondoo_policy_assignment" "enabled_policies" {
  space_id = mondoo_space.os_policy_testing.id

  policies = [
    "//policy.api.mondoo.app/policies/mondoo-linux-security",
    "//policy.api.mondoo.app/policies/mondoo-macos-security",
    "//policy.api.mondoo.app/policies/mondoo-windows-security",
    "//policy.api.mondoo.app/policies/amazon-linux-2023-level-1",
    "//policy.api.mondoo.app/policies/amazon-linux-2-level-1",
  ]

  state = "enabled" # default is enabled, we also support preview and disabled

  depends_on = [
    mondoo_space.os_policy_testing
  ]
}

resource "mondoo_policy_assignment" "disabled_policies" {
  space_id = mondoo_space.os_policy_testing.id

  policies = [
    "//policy.api.mondoo.app/policies/mondoo-aws-security",
    "//policy.api.mondoo.app/policies/mondoo-azure-security",
    "//policy.api.mondoo.app/policies/mondoo-aws-security",
    "//policy.api.mondoo.app/policies/mondoo-gcp-security",
    "//policy.api.mondoo.app/policies/mondoo-kubernetes-best-practices",
    "//policy.api.mondoo.app/policies/mondoo-kubernetes-security",
  ]

  state = "disabled" # default is enabled, we also support preview and disabled

  depends_on = [
    mondoo_space.os_policy_testing
  ]
}

resource "mondoo_policy_assignment" "preview_policies" {
  space_id = mondoo_space.os_policy_testing.id

  policies = [
    "//policy.api.mondoo.app/policies/amazon-linux-2023-level-2",
  ]

  state = "preview" # default is enabled, we also support preview and disabled

  depends_on = [
    mondoo_space.os_policy_testing
  ]
}

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

2 participants