Azure Lighthouse Assignment

This page shows how to write Terraform for Lighthouse Assignment and write them securely.

azurerm_lighthouse_assignment (Terraform)

The Assignment in Lighthouse can be configured in Terraform with the resource name azurerm_lighthouse_assignment. The following sections describe 6 examples of how to use the resource and its parameters.

Example Usage from GitHub

assignment.tf#L1
resource "azurerm_lighthouse_assignment" "subscriptionassignment" {
  count = try(coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
  try(var.settings.scopes.subscription.id, "")), "") != "" ? 1 : 0
  scope = coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
main.tf#L98
resource "azurerm_lighthouse_assignment" "developmentgroup" {
  scope                    = azurerm_lighthouse_definition.developmentgroup.scope
  lighthouse_definition_id = azurerm_lighthouse_definition.developmentgroup.id
  depends_on = [
    azurerm_lighthouse_definition.developmentgroup
  ]
assignment.tf#L1
resource "azurerm_lighthouse_assignment" "subscriptionassignment" {
  count = try(coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
  try(var.settings.scopes.subscription.id, "")), "") != "" ? 1 : 0
  scope = coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
assignment.tf#L1
resource "azurerm_lighthouse_assignment" "subscriptionassignment" {
  count = try(coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
  try(var.settings.scopes.subscription.id, "")), "") != "" ? 1 : 0
  scope = coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
assignment.tf#L1
resource "azurerm_lighthouse_assignment" "subscriptionassignment" {
  count = try(coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
  try(var.settings.scopes.subscription.id, "")), "") != "" ? 1 : 0
  scope = coalesce(
    try(format("/subscriptions/%s", var.resources["subscriptions"][try(var.settings.scopes.subscription.lz_key, var.client_config.landingzone_key)][var.settings.scopes.subscription.key].id), ""),
resources.tf#L25
resource "azurerm_lighthouse_assignment" "lighthouse_assign" {
  for_each = toset(var.scopes)

  scope                    = each.value
  lighthouse_definition_id = azurerm_lighthouse_definition.lighthouse_def.id
}

Review your Terraform file for Azure best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

Explanation in Terraform Registry

Manages a Lighthouse Assignment to a subscription, or to a resource group.

Azure Resource Manager Example

Azure Resource Manager code does not have the related resource.

Frequently asked questions

What is Azure Lighthouse Assignment?

Azure Lighthouse Assignment is a resource for Lighthouse of Microsoft Azure. Settings can be wrote in Terraform.

Where can I find the example code for the Azure Lighthouse Assignment?

For Terraform, the anmoltoppo/Terraform, azurenative/Azure and aztfmod/terraform-azurerm-caf source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.