Skip to content

azurermMonitorDataCollectionRuleAssociation

Manages a Data Collection Rule Association.

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 azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
  this,
  "example_1",
  {
    address_space: ["10.0.0.0/16"],
    location: azurermResourceGroupExample.location,
    name: "virtualnetwork",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermVirtualNetworkExample.overrideLogicalId("example");
const azurermMonitorDataCollectionEndpointExample =
  new azurerm.monitorDataCollectionEndpoint.MonitorDataCollectionEndpoint(
    this,
    "example_2",
    {
      location: azurermResourceGroupExample.location,
      name: "example-dce",
      resource_group_name: azurermResourceGroupExample.name,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMonitorDataCollectionEndpointExample.overrideLogicalId("example");
const azurermMonitorDataCollectionRuleExample =
  new azurerm.monitorDataCollectionRule.MonitorDataCollectionRule(
    this,
    "example_3",
    {
      data_flow: [
        {
          destinations: ["example-destination-metrics"],
          streams: ["Microsoft-InsightsMetrics"],
        },
      ],
      destinations: [
        {
          azure_monitor_metrics: [
            {
              name: "example-destination-metrics",
            },
          ],
        },
      ],
      location: azurermResourceGroupExample.location,
      name: "example-dcr",
      resource_group_name: azurermResourceGroupExample.name,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermMonitorDataCollectionRuleExample.overrideLogicalId("example");
const azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_4", {
  address_prefixes: ["10.0.2.0/24"],
  name: "subnet",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSubnetExample.overrideLogicalId("example");
const azurermNetworkInterfaceExample =
  new azurerm.networkInterface.NetworkInterface(this, "example_5", {
    ip_configuration: [
      {
        name: "internal",
        private_ip_address_allocation: "Dynamic",
        subnet_id: azurermSubnetExample.id,
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "nic",
    resource_group_name: azurermResourceGroupExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermNetworkInterfaceExample.overrideLogicalId("example");
const azurermLinuxVirtualMachineExample =
  new azurerm.linuxVirtualMachine.LinuxVirtualMachine(this, "example_6", {
    admin_password: "example-Password@7890",
    admin_username: "adminuser",
    disable_password_authentication: false,
    location: azurermResourceGroupExample.location,
    name: "machine",
    network_interface_ids: [azurermNetworkInterfaceExample.id],
    os_disk: [
      {
        caching: "ReadWrite",
        storage_account_type: "Standard_LRS",
      },
    ],
    resource_group_name: azurermResourceGroupExample.name,
    size: "Standard_B1ls",
    source_image_reference: [
      {
        offer: "UbuntuServer",
        publisher: "Canonical",
        sku: "16.04-LTS",
        version: "latest",
      },
    ],
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermLinuxVirtualMachineExample.overrideLogicalId("example");
new azurerm.monitorDataCollectionRuleAssociation.MonitorDataCollectionRuleAssociation(
  this,
  "example1",
  {
    data_collection_rule_id: azurermMonitorDataCollectionRuleExample.id,
    description: "example",
    name: "example1-dcra",
    target_resource_id: azurermLinuxVirtualMachineExample.id,
  }
);
new azurerm.monitorDataCollectionRuleAssociation.MonitorDataCollectionRuleAssociation(
  this,
  "example2",
  {
    data_collection_endpoint_id: azurermMonitorDataCollectionEndpointExample.id,
    description: "example",
    target_resource_id: azurermLinuxVirtualMachineExample.id,
  }
);

Arguments Reference

The following arguments are supported:

  • targetResourceId - (Required) The ID of the Azure Resource which to associate to a Data Collection Rule or a Data Collection Endpoint. Changing this forces a new resource to be created.

  • name - (Optional) The name which should be used for this Data Collection Rule Association. Changing this forces a new Data Collection Rule Association to be created. Defaults to configurationAccessEndpoint.

-> NOTE name is required when dataCollectionRuleId is specified. And when dataCollectionEndpointId is specified, the name is populated with configurationAccessEndpoint.

  • dataCollectionEndpointId - (Optional) The ID of the Data Collection Endpoint which will be associated to the target resource.

  • dataCollectionRuleId - (Optional) The ID of the Data Collection Rule which will be associated to the target resource.

-> NOTE Exactly one of dataCollectionEndpointId and dataCollectionRuleId blocks must be specified.

  • description - (Optional) The description of the Data Collection Rule Association.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Data Collection Rule Association.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the Data Collection Rule Association.
  • read - (Defaults to 5 minutes) Used when retrieving the Data Collection Rule Association.
  • update - (Defaults to 30 minutes) Used when updating the Data Collection Rule Association.
  • delete - (Defaults to 30 minutes) Used when deleting the Data Collection Rule Association.

Import

Data Collection Rules Association can be imported using the resourceId, e.g.

terraform import azurerm_monitor_data_collection_rule_association.example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1/providers/Microsoft.Insights/dataCollectionRuleAssociations/dca1