Skip to content

azurermApplicationInsightsWebTest

Manages an Application Insights WebTest.

Example Usage

import * as cdktf from "cdktf";
/*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: "tf-test",
  }
);
const azurermApplicationInsightsExample =
  new azurerm.applicationInsights.ApplicationInsights(this, "example_1", {
    application_type: "web",
    location: azurermResourceGroupExample.location,
    name: "tf-test-appinsights",
    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.*/
azurermApplicationInsightsExample.overrideLogicalId("example");
const azurermApplicationInsightsWebTestExample =
  new azurerm.applicationInsightsWebTest.ApplicationInsightsWebTest(
    this,
    "example_2",
    {
      application_insights_id: azurermApplicationInsightsExample.id,
      configuration:
        '<WebTest Name="WebTest1" Id="ABD48585-0831-40CB-9069-682EA6BB3583" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="" ResultsLocale="">\n  <Items>\n    <Request Method="GET" Guid="a5f10126-e4cd-570d-961c-cea43999a200" Version="1.1" Url="http://microsoft.com" ThinkTime="0" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="200" ExpectedResponseUrl="" ReportingName="" IgnoreHttpStatusCode="False" />\n  </Items>\n</WebTest>\n',
      enabled: true,
      frequency: 300,
      geo_locations: ["us-tx-sn1-azr", "us-il-ch1-azr"],
      kind: "ping",
      location: azurermApplicationInsightsExample.location,
      name: "tf-test-appinsights-webtest",
      resource_group_name: azurermResourceGroupExample.name,
      timeout: 60,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermApplicationInsightsWebTestExample.overrideLogicalId("example");
new cdktf.TerraformOutput(this, "webtest_id", {
  value: azurermApplicationInsightsWebTestExample.id,
});
new cdktf.TerraformOutput(this, "webtests_synthetic_id", {
  value: azurermApplicationInsightsWebTestExample.syntheticMonitorId,
});

Argument Reference

The following arguments are supported:

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

  • resourceGroupName - (Required) The name of the resource group in which to create the Application Insights WebTest. Changing this forces a new resource

  • applicationInsightsId - (Required) The ID of the Application Insights component on which the WebTest operates. 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. It needs to correlate with location of parent resource (azurerm_application_insights).

  • kind - (Required) The kind of web test that this web test watches. Choices are ping and multistep. Changing this forces a new resource to be created.

  • geoLocations - (Required) A list of where to physically run the tests from to give global coverage for accessibility of your application.

\~> Note: Valid options for geo locations are described here

  • configuration - (Required) An XML configuration specification for a WebTest (see here for more information).

  • frequency - (Optional) Interval in seconds between test runs for this WebTest. Valid options are 300, 600 and 900. Defaults to 300.

  • timeout - (Optional) Seconds until this WebTest will timeout and fail. Default is 30.

  • enabled - (Optional) Is the test actively being monitored.

  • retryEnabled - (Optional) Allow for retries should this WebTest fail.

  • description - (Optional) Purpose/user defined descriptive test for this WebTest.

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

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the Application Insights Web Test.
  • update - (Defaults to 30 minutes) Used when updating the Application Insights Web Test.
  • read - (Defaults to 5 minutes) Used when retrieving the Application Insights Web Test.
  • delete - (Defaults to 30 minutes) Used when deleting the Application Insights Web Test.

Import

Application Insights Web Tests can be imported using the resourceId, e.g.

terraform import azurerm_application_insights_web_test.my_test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Insights/webTests/my_test