microsoft / terraform-provider-power-platform

Power Platform Terraform Provider
https://registry.terraform.io/providers/microsoft/power-platform/latest/docs
MIT License
35 stars 13 forks source link

`powerplatform_enterprise_policy` #478

Closed mattdot closed 6 days ago

mattdot commented 1 month ago

Description

A policy is a pointer to an Azure resource (like Azure Key Vault). Policies can be added to multiple environments, as long as those environments are in the same region. Environments in different regions will need separate policies.

Creating a resource must link the environment to an existing enterprise policy in Azure. Destroying a resource must unlink.

Resource

Potential Terraform Configuration

# Sample Terraform config that describes how the new resource might look.

resource "powerplatform_enterprise_policy" "network_injection" {
  environment_id = "<guid>"
  policy_type = "NetworkInjection"
  body = jsonencode({
    SystemId = var.arm_enterprise_policy_id
  })
}

resource "powerplatform_enterprise_policy" "customer_managed_key" {
  environment_id = "<guid>"
  policy_type = "Encryption"
  body = jsonencode({
    SystemId = var.arm_encrytpion_key_id
  })
}

Definition of Done

Contributions

Do you plan to raise a PR to address this issue? YES / NO?

See the contributing guide for more information about what's expected for contributions.

webstean commented 1 month ago

I think, this is a vital addition to the provider, as it would be required by any non-trivial Power Platform implementation.

I'm not sure, why you need the json decode section, my recommendation would be:

# Sample Terraform config that describes how the new resource might look.

resource "powerplatform_enterprise_policy" "network_injection" {
  environment_id = "<guid>"
  policy_type = "NetworkInjection"
  policy_id = var.arm_enterprise_policy_id1
}

resource "powerplatform_enterprise_policy" "customer_managed_key" {
  environment_id = "<guid>"
  policy_type = "Encryption"
  policy_id = var.arm_enterprise_policy_id2
}
ronmanthe commented 1 month ago

I think, this is a vital addition to the provider, as it would be required by any non-trivial Power Platform implementation.

I'm not sure, why you need the json decode section, my recommendation would be:

# Sample Terraform config that describes how the new resource might look.

resource "powerplatform_enterprise_policy" "network_injection" {
  environment_id = "<guid>"
  policy_type = "NetworkInjection"
  policy_id = var.arm_enterprise_policy_id1
}

resource "powerplatform_enterprise_policy" "customer_managed_key" {
  environment_id = "<guid>"
  policy_type = "Encryption"
  policy_id = var.arm_enterprise_policy_id2
}

I second that! We are currently using terraform to build out our power platform environment and also need to use subnet injection.