Skip to content

Instantly share code, notes, and snippets.

@arcotek-ltd
Last active October 29, 2018 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arcotek-ltd/b108b96a6740173ee422bb043575010e to your computer and use it in GitHub Desktop.
Save arcotek-ltd/b108b96a6740173ee422bb043575010e to your computer and use it in GitHub Desktop.
Terraform issue
module "ResourceGroup" {
source = "..\\Modules\\NewResourceGroup"
resource_group_name = "${var.resource_group_name}"
location = "${var.location}"
tag_purpose = "${var.tag_purpose}"
tag_created_by = "${var.tag_created_by}"
tag_created_date = "${var.tag_created_date}"
tag_deployment_method = "${var.tag_deployment_method}"
}
module "TrafficManagerProfile" {
source = "..\\Modules\\NewTrafficManagerProfile"
resource_group_name = "${var.resource_group_name}"
tfmgr_instance_count = "${var.tfmgr_instance_count}"
tfmgr_routing_method = "${var.tfmgr_routing_method}"
tfmgr_ttl = "${var.tfmgr_ttl}"
tfmgr_protocol = "${var.tfmgr_protocol}"
}
module "RemoteStateGlobal" {
source = "..\\Modules\\RemoteState"
state_storage_account_name = "${var.state_storage_account_name}"
state_container_name = "${var.state_container_name}"
state_key = "${var.state_key}"
state_resource_group_name = "${var.state_resource_group_name}"
subscription_id = "${var.subscription_id}"
client_id = "${var.client_id}"
client_secret = "${var.client_secret}"
tenant_id = "${var.tenant_id}"
}
module "TrafficManagerEndpoint" {
source = "..\\Modules\\NewTrafficManagerEndpoint"
resource_group_name = "${module.RemoteStateGlobal.rs_resource_group_name}"
location = "${var.location}"
tfmgr_profile_name = "${element(module.RemoteStateGlobal.rs_tfmgr_profile_name,0)}"
tfmgr_target_resource_id = "${element(module.WebAppGroup.app_id,0)}"
tfmgr_type = "${var.tfmgr_type}"
tfmgr_weight = "${var.tfmgr_weight}"
tfep_instance_count = "${var.tfep_instance_count}"
}
data "terraform_remote_state" "global" {
backend = "azurerm"
config {
storage_account_name = "${var.state_storage_account_name}"
container_name = "${var.state_container_name}"
key = "${var.state_key}"
#access_key = "${var.state_access_key}"
resource_group_name = "${var.state_resource_group_name}"
arm_subscription_id = "${var.subscription_id}"
arm_client_id = "${var.client_id}"
arm_client_secret = "${var.client_secret}"
arm_tenant_id = "${var.tenant_id}"
}
}
resource "azurerm_resource_group" "resourceGroup" {
name = "${var.resource_group_name}"
location = "${var.location}"
tags = {
purpose = "${var.tag_purpose}"
createdBy = "${var.tag_created_by}"
createdDate = "${var.tag_created_date}"
deploymentMethod = "${var.tag_deployment_method}"
}
}
resource "azurerm_traffic_manager_endpoint" "traffic_manager_endpoint" {
count = "${var.tfep_instance_count}"
name = "${format("%s%02d%s", module.Namer_traffic_manager_endpoint.resource_name, count.index+1, lookup(var.failover_id, var.location))}"
resource_group_name = "${var.resource_group_name}"
profile_name = "${var.tfmgr_profile_name}"
target_resource_id = "${var.tfmgr_target_resource_id}"
type = "${var.tfmgr_type}"
weight = "${var.tfmgr_weight}"
}
resource "azurerm_traffic_manager_profile" "traffic_manager_profile" {
count = "${var.tfmgr_instance_count}"
#name = "${module.Namer_traffic_manager_profile.global_resource_name}"
name = "${var.tfmgr_instance_count == 1 ? format("%s%s", module.Namer_traffic_manager_profile.resource_name, "01") : format("${module.Namer_traffic_manager_profile.resource_name}%02d", count.index+1)}"
resource_group_name = "${var.resource_group_name}"
traffic_routing_method = "${var.tfmgr_routing_method}"
dns_config {
relative_name = "${format("%s%02d-%s", module.Namer_traffic_manager_profile.resource_name, count.index+1, "dns-config")}"
ttl = "${var.tfmgr_ttl}"
}
monitor_config {
protocol = "${var.tfmgr_protocol}"
port = 80
path = "/"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment