Terraform module for creation Azure Automation Runbook
locals {
current_date_plus_one_day = substr(timeadd(timestamp(),"24h"),0,10)
automation_runbook = {
# Runbook Parameters
runbook : {
name = "VMStartStop"
description = "Example VM Start/Stop script"
content = templatefile("../scripts/vm_stop.tftpl", {
name = "VMStartStop"
vm_id = data.azurerm_virtual_machine.example.id
subscription_id = data.azurerm_client_config.current.subscription_id
})
}
# Parameters of Runbook's Schedules to create
schedules : [{
name = "StartVM"
start_time = format("%sT09:00:00Z", local.current_date_plus_one_day)
parameters = {
action = "start"
}
}, {
name = "StopVM"
start_time = format("%sT09:00:00Z", local.current_date_plus_one_day)
parameters = {
action = "stop"
}
}]
}
}
data "azurerm_virtual_machine" "example" {
name = "vm"
resource_group_name = "example"
}
data "azurerm_automation_account" "example" {
name = "example"
resource_group_name = "example"
}
module "automation-runbook" {
source = "data-platform-hq/automation-runbook/azurerm"
version = "~> 1.0"
project = var.project
env = var.env
location = var.location
resource_group = data.azurerm_automation_account.example.resource_group_name
automation_account_name = data.azurerm_automation_account.example.name
runbook = local.automation_runbook.runbook
schedule = local.automation_runbook.schedules
}
Name | Version |
---|---|
terraform | >= 1.0.0 |
azurerm | >= 4.0.1 |
Name | Version |
---|---|
azurerm | >= 4.0.1 |
No modules.
Name | Type |
---|---|
azurerm_automation_job_schedule.this | resource |
azurerm_automation_runbook.this | resource |
azurerm_automation_schedule.this | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
automation_account_name | Automation Account name | string |
n/a | yes |
location | Azure location | string |
n/a | yes |
resource_group | Resource group name where Automation Account is located | string |
n/a | yes |
runbook | Objects with parameters to configure Runbook | object({ |
n/a | yes |
schedules | Set of objects with parameters to configure Schedules for Runbook | set(object({ |
[] |
no |
tags | Resource tags | map(any) |
{} |
no |
Name | Description |
---|---|
runbook_id | Automation Runbook Id |
Apache 2 Licensed. For more information please see LICENSE