-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sharmilamusunuru-master'
- Loading branch information
Showing
18 changed files
with
286 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module "automation_runbooks" { | ||
source = "./modules/automation/automation_runbook" | ||
for_each = local.shared_services.automation_runbooks | ||
|
||
global_settings = local.global_settings | ||
settings = each.value | ||
location = can(local.global_settings.regions[each.value.region]) ? local.global_settings.regions[each.value.region] : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)].location | ||
resource_group_name = can(each.value.resource_group.name) || can(each.value.resource_group_name) ? try(each.value.resource_group.name, each.value.resource_group_name) : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name | ||
base_tags = try(local.global_settings.inherit_tags, false) ? try(local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)].tags, {}) : {} | ||
client_config = local.client_config | ||
automation_account_name = can(each.value.automation_account_name) ? each.value.automation_account_name : local.combined_objects_automations[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.automation_account_key].name | ||
|
||
} | ||
|
||
output "automation_runbooks" { | ||
value = module.automation_runbooks | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
module "automation_schedules" { | ||
source = "./modules/automation/automation_schedule" | ||
for_each = local.shared_services.automation_schedules | ||
|
||
global_settings = local.global_settings | ||
settings = each.value | ||
location = can(local.global_settings.regions[each.value.region]) ? local.global_settings.regions[each.value.region] : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)].location | ||
resource_group_name = can(each.value.resource_group.name) || can(each.value.resource_group_name) ? try(each.value.resource_group.name, each.value.resource_group_name) : local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name | ||
base_tags = try(local.global_settings.inherit_tags, false) ? try(local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group.key, each.value.resource_group_key)].tags, {}) : {} | ||
client_config = local.client_config | ||
automation_account_name = can(each.value.automation_account_name) ? each.value.automation_account_name : local.combined_objects_automations[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.automation_account_key].name | ||
|
||
} | ||
|
||
output "automation_schedules" { | ||
value = module.automation_schedules | ||
} |
50 changes: 50 additions & 0 deletions
50
examples/automation/104-automation-schedule-runbook/configuration.tfvars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
global_settings = { | ||
default_region = "region1" | ||
regions = { | ||
region1 = "australiaeast" | ||
} | ||
} | ||
|
||
resource_groups = { | ||
automation = { | ||
name = "automation" | ||
} | ||
} | ||
|
||
automations = { | ||
auto1 = { | ||
name = "automation" | ||
sku = "basic" | ||
resource_group_key = "automation" | ||
} | ||
} | ||
|
||
automation_runbooks = { | ||
runbook1 = { | ||
name = "Get-AzureVMTutorial" | ||
resource_group_key = "automation" | ||
automation_account_key = "auto1" | ||
log_verbose = "true" | ||
log_progress = "true" | ||
description = "This is an example runbook" | ||
runbook_type = "PowerShellWorkflow" | ||
publish_content_link = { | ||
uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1" | ||
} | ||
} | ||
} | ||
|
||
automation_schedules = { | ||
schedule1 = { | ||
name = "tfex-automation-schedule" | ||
resource_group_key = "automation" | ||
automation_account_key = "auto1" | ||
frequency = "Week" | ||
interval = 1 | ||
timezone = "Australia/Perth" | ||
start_time = "2025-04-15T18:00:15+02:00" | ||
description = "This is an example schedule" | ||
week_days = ["Friday"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
locals { | ||
module_tag = { | ||
"module" = basename(abspath(path.module)) | ||
} | ||
tags = merge(var.base_tags, local.module_tag, try(var.settings.tags, null)) | ||
} | ||
|
||
|
||
terraform { | ||
required_providers { | ||
azurecaf = { | ||
source = "aztfmod/azurecaf" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# In some instances, the name of the runbook needs to match the name of workflow, using var.settings.name | ||
# | ||
# resource "azurecaf_name" "automation_runbook" { | ||
# name = var.settings.name | ||
# resource_type = "azurerm_automation_runbook" | ||
# prefixes = var.global_settings.prefixes | ||
# random_length = var.global_settings.random_length | ||
# clean_input = true | ||
# passthrough = var.global_settings.passthrough | ||
# use_slug = var.global_settings.use_slug | ||
# } | ||
|
||
resource "azurerm_automation_runbook" "automation_runbook" { | ||
name = var.settings.name | ||
location = var.location | ||
resource_group_name = var.resource_group_name | ||
automation_account_name = var.automation_account_name | ||
log_verbose = try(var.settings.log_verbose, null) | ||
log_progress = try(var.settings.log_progress, null) | ||
description = try(var.settings.description, null) | ||
runbook_type = var.settings.runbook_type | ||
|
||
content = try(var.settings.content, null) | ||
|
||
dynamic "publish_content_link" { | ||
for_each = try(var.settings.publish_content_link, null) == null ? [] : [1] | ||
|
||
content { | ||
uri = var.settings.publish_content_link.uri | ||
} | ||
} | ||
|
||
dynamic "timeouts" { | ||
for_each = lookup(var.settings, "timeouts", {}) == {} ? [] : [1] | ||
|
||
content { | ||
create = try(var.settings.timeouts.create, "30m") | ||
read = try(var.settings.timeouts.read, "30m") | ||
update = try(var.settings.timeouts.update, "30m") | ||
delete = try(var.settings.timeouts.delete, "30m") | ||
} | ||
} | ||
} | ||
|
||
# locals { | ||
# script_content = try(var.settings.script_file, null) != null ? file(var.settings.script_file) : var.settings.content | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "id" { | ||
description = "The Automation Account Runbook ID." | ||
value = azurerm_automation_runbook.automation_runbook.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
variable "resource_group_name" { | ||
description = "(Required) The name of the resource group where to create the resource." | ||
type = string | ||
} | ||
variable "automation_account_name" {} | ||
|
||
variable "location" { | ||
description = "(Required) Specifies the supported Azure location where to create the resource. Changing this forces a new resource to be created." | ||
type = string | ||
} | ||
|
||
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 = "Base tags for the resource to be inherited from the resource group." | ||
type = map(any) | ||
} | ||
|
||
variable "remote_objects" { | ||
description = "(Required) Specifies the supported Azure location where to create the resource. Changing this forces a new resource to be created." | ||
default = {} | ||
} | ||
|
||
variable "client_config" {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
locals { | ||
module_tag = { | ||
"module" = basename(abspath(path.module)) | ||
} | ||
tags = merge(var.base_tags, local.module_tag, try(var.settings.tags, null)) | ||
} | ||
|
||
|
||
terraform { | ||
required_providers { | ||
azurecaf = { | ||
source = "aztfmod/azurecaf" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
resource "azurecaf_name" "automation_schedule" { | ||
name = var.settings.name | ||
resource_type = "azurerm_automation_schedule" | ||
prefixes = var.global_settings.prefixes | ||
random_length = var.global_settings.random_length | ||
clean_input = true | ||
passthrough = var.global_settings.passthrough | ||
use_slug = var.global_settings.use_slug | ||
} | ||
|
||
resource "azurerm_automation_schedule" "automation_schedule" { | ||
name = azurecaf_name.automation_schedule.result | ||
resource_group_name = var.resource_group_name | ||
automation_account_name = var.automation_account_name | ||
frequency = var.settings.frequency | ||
interval = try(var.settings.interval, null) | ||
timezone = try(var.settings.timezone, null) | ||
start_time = try(var.settings.start_time, null) | ||
description = try(var.settings.description, null) | ||
week_days = try(var.settings.week_days, null) | ||
month_days = try(var.settings.month_days, null) | ||
|
||
dynamic "monthly_occurrence" { | ||
for_each = try(var.settings.monthly_occurrences, null) == null ? [] : [1] | ||
|
||
content { | ||
day = monthly_occurrence.day | ||
occurrence = monthly_occurrence.occurrence | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
output "id" { | ||
description = "The Automation Account Schedule ID." | ||
value = azurerm_automation_schedule.automation_schedule.id | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
variable "resource_group_name" { | ||
description = "(Required) The name of the resource group where to create the resource." | ||
type = string | ||
} | ||
variable "automation_account_name" {} | ||
|
||
variable "location" { | ||
description = "(Required) Specifies the supported Azure location where to create the resource. Changing this forces a new resource to be created." | ||
type = string | ||
} | ||
|
||
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 = "Base tags for the resource to be inherited from the resource group." | ||
type = map(any) | ||
} | ||
|
||
variable "remote_objects" { | ||
description = "(Required) Specifies the supported Azure location where to create the resource. Changing this forces a new resource to be created." | ||
default = {} | ||
} | ||
|
||
variable "client_config" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters