Skip to content

azurermTrafficManagerProfile

Manages a Traffic Manager Profile to which multiple endpoints can be attached.

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";
import * as random from "./.gen/providers/random";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm, random.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "trafficmanagerProfile",
  }
);
const randomIdServer = new random.id.Id(this, "server", {
  byte_length: 8,
  keepers: [
    {
      azi_id: 1,
    },
  ],
});
const azurermTrafficManagerProfileExample =
  new azurerm.trafficManagerProfile.TrafficManagerProfile(this, "example_2", {
    dns_config: [
      {
        relative_name: randomIdServer.hex,
        ttl: 100,
      },
    ],
    monitor_config: [
      {
        interval_in_seconds: 30,
        path: "/",
        port: 80,
        protocol: "HTTP",
        timeout_in_seconds: 9,
        tolerated_number_of_failures: 3,
      },
    ],
    name: randomIdServer.hex,
    resource_group_name: azurermResourceGroupExample.name,
    tags: {
      environment: "Production",
    },
    traffic_routing_method: "Weighted",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermTrafficManagerProfileExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) The name of the Traffic Manager profile. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which to create the Traffic Manager profile. Changing this forces a new resource to be created.

  • profileStatus - (Optional) The status of the profile, can be set to either enabled or disabled. Defaults to enabled.

  • trafficRoutingMethod - (Required) Specifies the algorithm used to route traffic. Possible values are geographic, weighted, performance, priority, subnet and multiValue.

    • geographic - Traffic is routed based on Geographic regions specified in the Endpoint.
    • multiValue - All healthy Endpoints are returned. MultiValue routing method works only if all the endpoints of type ‘External’ and are specified as IPv4 or IPv6 addresses.
    • performance - Traffic is routed via the User's closest Endpoint
    • priority - Traffic is routed to the Endpoint with the lowest priority value.
    • subnet - Traffic is routed based on a mapping of sets of end-user IP address ranges to a specific Endpoint within a Traffic Manager profile.
    • weighted - Traffic is spread across Endpoints proportional to their weight value.
  • trafficViewEnabled - (Optional) Indicates whether Traffic View is enabled for the Traffic Manager profile.

  • dnsConfig - (Required) This block specifies the DNS configuration of the Profile, it supports the fields documented below.

  • monitorConfig - (Required) This block specifies the Endpoint monitoring configuration for the Profile, it supports the fields documented below.

  • maxReturn - (Optional) The amount of endpoints to return for DNS queries to this Profile. Possible values range from 1 to 8.

\~> NOTE: maxReturn must be set when the trafficRoutingMethod is multiValue.

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

The dnsConfig block supports:

  • relativeName - (Required) The relative domain name, this is combined with the domain name used by Traffic Manager to form the FQDN which is exported as documented below. Changing this forces a new resource to be created.

  • ttl - (Required) The TTL value of the Profile used by Local DNS resolvers and clients.


The monitorConfig block supports:

  • protocol - (Required) The protocol used by the monitoring checks, supported values are http, https and tcp.

  • port - (Required) The port number used by the monitoring checks.

  • path - (Optional) The path used by the monitoring checks. Required when protocol is set to http or https - cannot be set when protocol is set to tcp.

  • expectedStatusCodeRanges - (Optional) A list of status code ranges in the format of 100101.

  • customHeader - (Optional) One or more customHeader blocks as defined below.

  • intervalInSeconds - (Optional) The interval used to check the endpoint health from a Traffic Manager probing agent. You can specify two values here: 30 (normal probing) and 10 (fast probing). The default value is 30.

  • timeoutInSeconds - (Optional) The amount of time the Traffic Manager probing agent should wait before considering that check a failure when a health check probe is sent to the endpoint. If intervalInSeconds is set to 30, then timeoutInSeconds can be between 5 and 10. The default value is 10. If intervalInSeconds is set to 10, then valid values are between 5 and 9 and timeoutInSeconds is required.

  • toleratedNumberOfFailures - (Optional) The number of failures a Traffic Manager probing agent tolerates before marking that endpoint as unhealthy. Valid values are between 0 and 9. The default value is 3


A customHeader block supports the following:

  • name - (Required) The name of the custom header.

  • value - (Required) The value of custom header. Applicable for HTTP and HTTPS protocol.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Traffic Manager Profile.

  • fqdn - The FQDN of the created Profile.

Timeouts

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

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

Import

Traffic Manager Profiles can be imported using the resourceId, e.g.

terraform import azurerm_traffic_manager_profile.exampleProfile /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/trafficManagerProfiles/mytrafficmanagerprofile1