Skip to content

azurermAutomationRunbook

Manages a Automation Runbook.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermAutomationAccountExample =
  new azurerm.automationAccount.AutomationAccount(this, "example_1", {
    location: azurermResourceGroupExample.location,
    name: "account1",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "Basic",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermAutomationAccountExample.overrideLogicalId("example");
const azurermAutomationRunbookExample =
  new azurerm.automationRunbook.AutomationRunbook(this, "example_2", {
    automation_account_name: azurermAutomationAccountExample.name,
    description: "This is an example runbook",
    location: azurermResourceGroupExample.location,
    log_progress: "true",
    log_verbose: "true",
    name: "Get-AzureVMTutorial",
    publish_content_link: [
      {
        uri: "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/c4935ffb69246a6058eb24f54640f53f69d3ac9f/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1",
      },
    ],
    resource_group_name: azurermResourceGroupExample.name,
    runbook_type: "PowerShellWorkflow",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermAutomationRunbookExample.overrideLogicalId("example");

Example Usage - custom content

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
import * as local from "./.gen/providers/local";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm, local.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const dataLocalFileExample = new local.dataLocalFile.DataLocalFile(
  this,
  "example_1",
  {
    filename: "${path.module}/example.ps1",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataLocalFileExample.overrideLogicalId("example");
const azurermAutomationAccountExample =
  new azurerm.automationAccount.AutomationAccount(this, "example_2", {
    location: azurermResourceGroupExample.location,
    name: "account1",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "Basic",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermAutomationAccountExample.overrideLogicalId("example");
const azurermAutomationRunbookExample =
  new azurerm.automationRunbook.AutomationRunbook(this, "example_3", {
    automation_account_name: azurermAutomationAccountExample.name,
    content: dataLocalFileExample.content,
    description: "This is an example runbook",
    location: azurermResourceGroupExample.location,
    log_progress: "true",
    log_verbose: "true",
    name: "Get-AzureVMTutorial",
    resource_group_name: azurermResourceGroupExample.name,
    runbook_type: "PowerShell",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermAutomationRunbookExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Runbook. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which the Runbook is created. Changing this forces a new resource to be created.

  • location - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created.

  • automationAccountName - (Required) The name of the automation account in which the Runbook is created. Changing this forces a new resource to be created.

  • runbookType - (Required) The type of the runbook - can be either graph, graphPowerShell, graphPowerShellWorkflow, powerShellWorkflow, powerShell, python3, python2 or script. Changing this forces a new resource to be created.

  • logProgress - (Required) Progress log option.

  • logVerbose - (Required) Verbose log option.

  • publishContentLink - (Optional) The published runbook content link.

  • description - (Optional) A description for this credential.

  • content - (Optional) The desired content of the runbook.

\~> NOTE The Azure API requires a publishContentLink to be supplied even when specifying your own content.

  • tags - (Optional) A mapping of tags to assign to the resource.

  • logActivityTraceLevel - (Optional) Specifies the activity-level tracing options of the runbook, available only for Graphical runbooks. Possible values are 0 for None, 9 for Basic, and 15 for Detailed. Must turn on Verbose logging in order to see the tracing.

  • draft - (Optional) A draft block as defined below .


The publishContentLink block supports the following:

  • uri - (Required) The URI of the runbook content.

  • version - (Optional) Specifies the version of the content

  • hash - (Optional) A hash block as defined below.


The hash block supports:

  • algorithm - (Required) Specifies the hash algorithm used to hash the content.

  • value - (Required) Specifies the expected hash value of the content.


The draft block supports:

  • editModeEnabled - (Optional) Whether the draft in edit mode.

  • contentLink - (Optional) A publishContentLink block as defined above.

  • outputTypes - (Optional) Specifies the output types of the runbook.

  • parameters - (Optional) A list of parameters block as defined below.


The parameters block supports:

  • key - (Required) The name of the parameter.

  • type - (Required) Specifies the type of this parameter.

  • mandatory - (Optional) Whether this parameter is mandatory.

  • position - (Optional) Specifies the position of the parameter.

  • defaultValue - (Optional) Specifies the default value of the parameter.

Attributes Reference

The following attributes are exported:

  • id - The Automation Runbook ID.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Automation Runbook.
  • update - (Defaults to 30 minutes) Used when updating the Automation Runbook.
  • read - (Defaults to 5 minutes) Used when retrieving the Automation Runbook.
  • delete - (Defaults to 30 minutes) Used when deleting the Automation Runbook.

Import

Automation Runbooks can be imported using the resourceId, e.g.

terraform import azurerm_automation_runbook.Get-AzureVMTutorial /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Automation/automationAccounts/account1/runbooks/Get-AzureVMTutorial