diff --git a/.github/workflows/standalone-scenarios.json b/.github/workflows/standalone-scenarios.json index 2bd6a3da02..9ca4d90121 100644 --- a/.github/workflows/standalone-scenarios.json +++ b/.github/workflows/standalone-scenarios.json @@ -29,6 +29,7 @@ "automation/102-automation-msi", "automation/103-automation-private-endpoints", "automation/104-automation-schedule-runbook", + "automation/105-automation-powershell-module", "communication/communication_services/101-communication_service", "diagnostics_profiles/100-multiple-destinations", "diagnostics_profiles/100-multiple-destinations", diff --git a/automation_modules.tf b/automation_modules.tf new file mode 100644 index 0000000000..665ff10d3d --- /dev/null +++ b/automation_modules.tf @@ -0,0 +1,14 @@ +module "automation_powershell72_module" { + source = "./modules/automation/automation_module/automation_powershell72_module" + for_each = local.shared_services.automation_powershell72_module + + global_settings = local.global_settings + settings = each.value + client_config = local.client_config + automation_account_id = can(each.value.automation_account_id) ? each.value.automation_account_id : local.combined_objects_automations[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.automation_account_key].id + base_tags = local.global_settings.inherit_tags +} + +output "automation_powershell72_module" { + value = module.automation_powershell72_module +} diff --git a/examples/automation/105-automation-powershell-module/configuration.tfvars b/examples/automation/105-automation-powershell-module/configuration.tfvars new file mode 100644 index 0000000000..e9d34e0790 --- /dev/null +++ b/examples/automation/105-automation-powershell-module/configuration.tfvars @@ -0,0 +1,30 @@ +global_settings = { + default_region = "region1" + regions = { + region1 = "australiaeast" + } +} + +resource_groups = { + automation = { + name = "automation" + } +} + +automations = { + auto1 = { + name = "automation" + sku = "Basic" + resource_group_key = "automation" + } +} + +automation_powershell72_module = { + module1 = { + name = "Az.ResourceGraph" + automation_account_key = "auto1" + module_link = { + uri = "https://www.powershellgallery.com/api/v2/package/Az.ResourceGraph/1.0.0" + } + } +} diff --git a/examples/azuread/107-azuread-application-with-single-page-application/configuration.tfvars b/examples/azuread/107-azuread-application-with-single-page-application/configuration.tfvars index be32857be7..a8a7b91a7e 100644 --- a/examples/azuread/107-azuread-application-with-single-page-application/configuration.tfvars +++ b/examples/azuread/107-azuread-application-with-single-page-application/configuration.tfvars @@ -56,8 +56,8 @@ azuread_applications = { admin_consent_description = "Allow to administer app2." admin_consent_display_name = "Administer app2" enabled = true - type = "Admin" - value = "app2" + type = "Admin" + value = "app2" } ] } diff --git a/examples/module.tf b/examples/module.tf index f2fbbc1c6c..94263ead40 100644 --- a/examples/module.tf +++ b/examples/module.tf @@ -300,6 +300,7 @@ module "example" { shared_services = { automations = var.automations + automation_powershell72_module = var.automation_powershell72_module automation_schedules = var.automation_schedules automation_runbooks = var.automation_runbooks automation_log_analytics_links = var.automation_log_analytics_links diff --git a/examples/variables.tf b/examples/variables.tf index 53625d0dd2..a18f6e9924 100644 --- a/examples/variables.tf +++ b/examples/variables.tf @@ -506,6 +506,9 @@ variable "event_hubs" { variable "automations" { default = {} } +variable "automation_powershell72_module" { + default = {} +} variable "automation_schedules" { default = {} } diff --git a/locals.tf b/locals.tf index e81350b46f..723bd58a84 100644 --- a/locals.tf +++ b/locals.tf @@ -380,6 +380,7 @@ locals { shared_services = { automations = try(var.shared_services.automations, {}) + automation_powershell72_module = try(var.shared_services.automation_powershell72_module, {}) automation_schedules = try(var.shared_services.automation_schedules, {}) automation_runbooks = try(var.shared_services.automation_runbooks, {}) automation_log_analytics_links = try(var.shared_services.automation_log_analytics_links, {}) diff --git a/modules/automation/automation_module/automation_powershell_module/main.tf b/modules/automation/automation_module/automation_powershell_module/main.tf new file mode 100644 index 0000000000..bd414805b7 --- /dev/null +++ b/modules/automation/automation_module/automation_powershell_module/main.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + azurecaf = { + source = "aztfmod/azurecaf" + } + } +} + +locals { + tags = var.base_tags ? merge( + var.global_settings.tags, + try(var.settings.tags, null) + ) : try(var.settings.tags, null) +} diff --git a/modules/automation/automation_module/automation_powershell_module/module.tf b/modules/automation/automation_module/automation_powershell_module/module.tf new file mode 100644 index 0000000000..e1da8e9556 --- /dev/null +++ b/modules/automation/automation_module/automation_powershell_module/module.tf @@ -0,0 +1,18 @@ +resource "azurerm_automation_powershell72_module" "automation_powershell72_module" { + name = var.settings.name + automation_account_id = var.automation_account_id + tags = local.tags + + module_link { + uri = var.settings.module_link.uri + + dynamic "hash" { + for_each = try(var.settings.module_link.hash, null) == null ? [] : [1] + + content { + algorithm = hash.algorithm + value = hash.value + } + } + } +} diff --git a/modules/automation/automation_module/automation_powershell_module/output.tf b/modules/automation/automation_module/automation_powershell_module/output.tf new file mode 100644 index 0000000000..5dd86bb0c1 --- /dev/null +++ b/modules/automation/automation_module/automation_powershell_module/output.tf @@ -0,0 +1,4 @@ +output "id" { + description = "The Automation Module ID." + value = azurerm_automation_powershell72_module.automation_powershell72_module.id +} diff --git a/modules/automation/automation_module/automation_powershell_module/variables.tf b/modules/automation/automation_module/automation_powershell_module/variables.tf new file mode 100644 index 0000000000..fc8002befb --- /dev/null +++ b/modules/automation/automation_module/automation_powershell_module/variables.tf @@ -0,0 +1,15 @@ +variable "automation_account_id" {} + +variable "settings" { + description = "Configuration object for the Automation account schedule." +} + +variable "global_settings" { + description = "Global settings object (see module README.md)" +} +variable "base_tags" { + description = "Enable tags inheritence." + type = bool +} + +variable "client_config" {}