Skip to content

azurermLogAnalyticsLinkedService

Manages a Log Analytics Linked Service.

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: "resourcegroup-01",
  }
);
const azurermAutomationAccountExample =
  new azurerm.automationAccount.AutomationAccount(this, "example_1", {
    location: azurermResourceGroupExample.location,
    name: "automation-01",
    resource_group_name: azurermResourceGroupExample.name,
    sku_name: "Basic",
    tags: {
      environment: "development",
    },
  });
/*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 azurermLogAnalyticsWorkspaceExample =
  new azurerm.logAnalyticsWorkspace.LogAnalyticsWorkspace(this, "example_2", {
    location: azurermResourceGroupExample.location,
    name: "workspace-01",
    resource_group_name: azurermResourceGroupExample.name,
    retention_in_days: 30,
    sku: "PerGB2018",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLogAnalyticsWorkspaceExample.overrideLogicalId("example");
const azurermLogAnalyticsLinkedServiceExample =
  new azurerm.logAnalyticsLinkedService.LogAnalyticsLinkedService(
    this,
    "example_3",
    {
      read_access_id: azurermAutomationAccountExample.id,
      resource_group_name: azurermResourceGroupExample.name,
      workspace_id: azurermLogAnalyticsWorkspaceExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLogAnalyticsLinkedServiceExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

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

  • workspaceId - (Required) The ID of the Log Analytics Workspace that will contain the Log Analytics Linked Service resource.

  • readAccessId - (Optional) The ID of the readable Resource that will be linked to the workspace. This should be used for linking to an Automation Account resource.

  • writeAccessId - (Optional) The ID of the writable Resource that will be linked to the workspace. This should be used for linking to a Log Analytics Cluster resource.

\~> NOTE: You must define at least one of the above access resource id attributes (e.g. readAccessId or writeAccessId).

Attributes Reference

The following attributes are exported:

  • id - The Log Analytics Linked Service ID.

  • name - The generated name of the Linked Service. The format for this attribute is always <workspaceName>/<linkedServiceType>(e.g. workspace1/automation or workspace1/cluster)

Timeouts

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

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

Import

Log Analytics Workspaces can be imported using the resourceId, e.g.

terraform import azurerm_log_analytics_linked_service.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.OperationalInsights/workspaces/workspace1/linkedServices/Automation