terraform-azurerm-caf-enter.../resources.policy_assignment...

47 строки
2.4 KiB
Terraform
Исходник Обычный вид История

2020-09-25 22:39:19 +03:00
resource "azurerm_policy_assignment" "enterprise_scale" {
2020-10-09 15:45:50 +03:00
for_each = local.azurerm_policy_assignment_enterprise_scale
2020-09-25 22:39:19 +03:00
# Mandatory resource attributes
# The policy assignment name length must not exceed '24' characters, but Terraform plan is unable to validate this in the plan stage. The following logic forces an error during plan if an invalid name length is specified.
name = tonumber(length(each.value.template.name) > 24 ? "The policy assignment name '${each.value.template.name}' is invalid. The policy assignment name length must not exceed '24' characters." : length(each.value.template.name)) > 24 ? null : each.value.template.name
scope = each.value.scope_id
policy_definition_id = each.value.template.properties.policyDefinitionId
# Optional resource attributes
identity {
type = try(each.value.template.identity.type, "None")
2020-09-25 22:39:19 +03:00
}
location = try(each.value.template.location, null)
description = try(each.value.template.properties.description, "${each.value.template.name} Policy Assignment at scope ${each.value.scope_id}")
display_name = try(each.value.template.properties.displayName, each.value.template.name)
metadata = try(length(each.value.template.properties.metadata) > 0, false) ? jsonencode(each.value.template.properties.metadata) : null
parameters = try(length(each.value.parameters) > 0, false) ? jsonencode(each.value.parameters) : null
not_scopes = try(each.value.template.properties.notScopes, local.empty_list)
enforcement_mode = each.value.enforcement_mode
2020-09-25 22:39:19 +03:00
# Set explicit dependency on Management Group, Policy Definition and Policy Set Definition deployments
2020-09-25 22:39:19 +03:00
depends_on = [
Library template update automation, and bug fixes (#44) - Update Unit and E2E test pipelines to use YML templates and dynamic matrix generation. - Add custom PS module for `Enterprise Scale Library Tools` to handle automated library template updates. - Add script and GitHub Action to enable automated library template updates from [Azure/Enterprise-Scale](https://github.com/Azure/Enterprise-Scale) repository using a CI pipeline. - Add offline ProviderApiVersions cache in `Enterprise Scale Library Tools` to negate the need for Azure credentials. - Update Library Templates (automated) using new CI process. - Manual remediations to updated library templates to ensure full compatibility with Terraform (needs to be fixed at source to prevent regression). - Update Policy Assignments and archetypes to provide parity with [WingTip reference Enterprise-Scale foundations](https://github.com/Azure/Enterprise-Scale/blob/main/docs/reference/wingtip/README.md). - Update Resource definitions in base module to use `name` field instead of `properties.displayName` to allow setting a more "human-friendly" displayName on policies and roles. - Fix bug where duplicate roles are created at the same scope for policy assignments with managed identity. - Add customizable delay between deployment of different resource types to reduce deployment errors due to caching and replication in the Azure API (Improvement to help Fix #37). - Update `root_parent_id` validation regex to include support for additional supported characters (Fix #43).
2021-03-06 22:29:26 +03:00
time_sleep.after_azurerm_management_group,
time_sleep.after_azurerm_policy_definition,
time_sleep.after_azurerm_policy_set_definition,
2020-09-25 22:39:19 +03:00
]
}
Library template update automation, and bug fixes (#44) - Update Unit and E2E test pipelines to use YML templates and dynamic matrix generation. - Add custom PS module for `Enterprise Scale Library Tools` to handle automated library template updates. - Add script and GitHub Action to enable automated library template updates from [Azure/Enterprise-Scale](https://github.com/Azure/Enterprise-Scale) repository using a CI pipeline. - Add offline ProviderApiVersions cache in `Enterprise Scale Library Tools` to negate the need for Azure credentials. - Update Library Templates (automated) using new CI process. - Manual remediations to updated library templates to ensure full compatibility with Terraform (needs to be fixed at source to prevent regression). - Update Policy Assignments and archetypes to provide parity with [WingTip reference Enterprise-Scale foundations](https://github.com/Azure/Enterprise-Scale/blob/main/docs/reference/wingtip/README.md). - Update Resource definitions in base module to use `name` field instead of `properties.displayName` to allow setting a more "human-friendly" displayName on policies and roles. - Fix bug where duplicate roles are created at the same scope for policy assignments with managed identity. - Add customizable delay between deployment of different resource types to reduce deployment errors due to caching and replication in the Azure API (Improvement to help Fix #37). - Update `root_parent_id` validation regex to include support for additional supported characters (Fix #43).
2021-03-06 22:29:26 +03:00
resource "time_sleep" "after_azurerm_policy_assignment" {
depends_on = [
time_sleep.after_azurerm_management_group,
time_sleep.after_azurerm_policy_definition,
time_sleep.after_azurerm_policy_set_definition,
azurerm_policy_assignment.enterprise_scale,
]
triggers = {
"azurerm_policy_assignment_enterprise_scale" = jsonencode(keys(azurerm_policy_assignment.enterprise_scale))
}
create_duration = local.create_duration_delay["after_azurerm_policy_assignment"]
destroy_duration = local.destroy_duration_delay["after_azurerm_policy_assignment"]
}