Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automation powershell module #2064

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .github/workflows/standalone-scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions automation_modules.tf
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions examples/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions examples/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ variable "event_hubs" {
variable "automations" {
default = {}
}
variable "automation_powershell72_module" {
default = {}
}
variable "automation_schedules" {
default = {}
}
Expand Down
1 change: 1 addition & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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, {})
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "id" {
description = "The Automation Module ID."
value = azurerm_automation_powershell72_module.automation_powershell72_module.id
}
Original file line number Diff line number Diff line change
@@ -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" {}
Loading