quickstart/101-azure-automation/main.tf (33 lines of code) (raw):

resource "random_pet" "rg_name" { prefix = var.resource_group_name_prefix } resource "azurerm_resource_group" "rg" { location = var.resource_group_location name = random_pet.rg_name.id } resource "random_string" "azurerm_automation_account_name" { length = 13 lower = true numeric = false special = false upper = false } resource "azurerm_automation_account" "example" { name = coalesce(var.automation_account_name, "autoacc-${random_string.azurerm_automation_account_name.result}") resource_group_name = azurerm_resource_group.rg.name location = azurerm_resource_group.rg.location sku_name = "Basic" identity { type = "SystemAssigned" } public_network_access_enabled = true } data "azurerm_subscription" "current" {} data "azurerm_role_definition" "contributor" { name = "Contributor" } resource "azurerm_role_assignment" "example" { scope = data.azurerm_subscription.current.id role_definition_name = "Contributor" principal_id = azurerm_automation_account.example.identity[0].principal_id }