github.com/skyscape-cloud-services/terraform@v0.9.2-0.20170609144644-7ece028a1747/examples/azure-traffic-manager-lb-scale-set/main.tf (about)

     1  # Provider accounts must be passed 
     2  
     3  variable "subscription_id" {}
     4  variable "client_id" {}
     5  variable "client_secret" {}
     6  variable "tenant_id" {}
     7  
     8  provider "azurerm" {
     9    subscription_id = "${var.subscription_id}"
    10    client_id       = "${var.client_id}"
    11    client_secret   = "${var.client_secret}"
    12    tenant_id       = "${var.tenant_id}"
    13    }
    14  
    15  # Create the resource group and assets for first location
    16  module "location01" {
    17    source                = "./tf_modules"
    18  
    19    location              = "${var.location01_location}"
    20    resource_prefix       = "${var.location01_resource_prefix}"
    21    webserver_prefix      = "${var.location01_webserver_prefix}"
    22    lb_dns_label          = "${var.location01_lb_dns_label}"  
    23    
    24    instance_count        = "${var.instance_count}"
    25    instance_vmprofile    = "${var.instance_vmprofile}"
    26  
    27    image_admin_username  = "${var.image_admin_username}"
    28    image_admin_password  = "${var.image_admin_password}"
    29  
    30    image_publisher       = "${var.image_publisher}"
    31    image_offer           = "${var.image_offer}"
    32    image_sku             = "${var.image_sku}"
    33    image_version         = "${var.image_version}"
    34    
    35  }
    36  
    37  # Create the resource group and assets for second location
    38  module "location02" {
    39    source             = "./tf_modules"
    40  
    41    location           = "${var.location02_location}"
    42    resource_prefix    = "${var.location02_resource_prefix}"
    43    webserver_prefix   = "${var.location02_webserver_prefix}"
    44    lb_dns_label       = "${var.location02_lb_dns_label}"  
    45  
    46    instance_count     = "${var.instance_count}"
    47    instance_vmprofile = "${var.instance_vmprofile}"
    48  
    49    image_admin_username  = "${var.image_admin_username}"
    50    image_admin_password  = "${var.image_admin_password}"
    51  
    52    image_publisher       = "${var.image_publisher}"
    53    image_offer           = "${var.image_offer}"
    54    image_sku             = "${var.image_sku}"
    55    image_version         = "${var.image_version}"
    56  
    57  }
    58  
    59  # Create global resource group
    60  resource "azurerm_resource_group" "global_rg" {
    61    name     = "global_rg"
    62    location = "${var.global_location}"
    63  }
    64  
    65  # Create the traffic manager
    66  resource "azurerm_traffic_manager_profile" "trafficmanagerhttp" {
    67    name                = "trafficmanagerhttp"
    68    resource_group_name = "${azurerm_resource_group.global_rg.name}"
    69  
    70    traffic_routing_method = "Weighted"
    71  
    72    dns_config {
    73      relative_name = "${var.dns_relative_name}"
    74      ttl           = 100
    75    }
    76  
    77    monitor_config {
    78      protocol = "http"
    79      port     = 80
    80      path     = "/"
    81    }
    82  }
    83  
    84  # Add endpoint mappings to traffic manager, location01
    85  resource "azurerm_traffic_manager_endpoint" "trafficmanagerhttp_01" {
    86    name                = "trafficmanagerhttp_ukw"
    87    resource_group_name = "${azurerm_resource_group.global_rg.name}"
    88    profile_name        = "${azurerm_traffic_manager_profile.trafficmanagerhttp.name}"
    89    target_resource_id  = "${module.location01.webserverpublic_ip_id}"
    90    type                = "azureEndpoints"
    91    weight              = 100
    92  }
    93  
    94  # Add endpoint mappings to traffic manager, location02
    95  resource "azurerm_traffic_manager_endpoint" "trafficmanagerhttp_02" {
    96    name                = "trafficmanagerhttp_wus"
    97    resource_group_name = "${azurerm_resource_group.global_rg.name}"
    98    profile_name        = "${azurerm_traffic_manager_profile.trafficmanagerhttp.name}"
    99    target_resource_id  = "${module.location02.webserverpublic_ip_id}"
   100    type                = "azureEndpoints"
   101    weight              = 100
   102  }