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
}
Parameters
-
id
optional computed - string -
lighthouse_definition_id
required - string -
name
optional computed - string -
scope
required - string -
timeouts
single block
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.