首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于交通管理器的Terraform脚本引发未知错误

用于交通管理器的Terraform脚本引发未知错误
EN

Stack Overflow用户
提问于 2017-10-30 12:29:49
回答 1查看 587关注 0票数 1

我在部署交通管理器时遇到了错误。这可能是非常基本的配置。然而,它说,不知道的服务错误,我没有线索来解决这个问题。

代码语言:javascript
复制
Terraform Version

Terraform v0.10.0

服务原则

代码语言:javascript
复制
variable "subscription_id" {}

variable "client_id" {}

variable "client_secret" {}        

variable "tenant_id" {}    

资源组

变量"resource_group“{}

变量“位置”{}

变量“环境”{}

实际脚本

代码语言:javascript
复制
  # Service Principle
    provider "azurerm" {
      subscription_id = "${var.subscription_id}"
      client_id       = "${var.client_id}"
      client_secret   = "${var.client_secret}"
      tenant_id       = "${var.tenant_id}"
    }

    # Traffic Manager Profile

    resource "azurerm_traffic_manager_profile" "profile" {
  name                   = "trafficmanagerprofile"
  resource_group_name    = "production"
  traffic_routing_method = "Weighted"

  dns_config {
    relative_name = "production"
    ttl           = 30
  }

  monitor_config {
    protocol = "http"
    port     = 80
    path     = "/"
  }
}

resource "azurerm_public_ip" "pip" {
  name                         = "ip${count.index}"
  location                     = "${var.azure_region}"
  resource_group_name          = "production"
  public_ip_address_allocation = "dynamic"
  domain_name_label            = "${var.dns_name}${count.index}"
  count                        = "${var.num_vms}"
}

resource "azurerm_traffic_manager_endpoint" "endpoint" {
  name                = "endpoint${count.index}"
  resource_group_name = "production"
  profile_name        = "${azurerm_traffic_manager_profile.profile.name}"
  target_resource_id  = "${element(azurerm_public_ip.pip.*.id, count.index)}"
  type                = "azureEndpoints"
  weight              = 1
  count               = "${var.num_vms}"
}

Debug Output

Error: autorest/azure: Service returned an error. Status=400 Code="Unknown" Message="Unknown service error"

预期行为

代码语言:javascript
复制
It should be create a Traffic Manager Profile instance on Azure

实际行为

代码语言:javascript
复制
Resource Group created but traffic manager profile throws error.

I am struggling with this from long time can anybody help me out here?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-31 02:01:09

请使用以下脚本,它适用于我。

代码语言:javascript
复制
  resource "azurerm_traffic_manager_profile" "profile" {
  name                   = "trafficmanagerprofile"
  resource_group_name    = "shuioracle"
  traffic_routing_method = "Weighted"

  dns_config {
    relative_name = "shuioracle"
    ttl           = 30
  }

  monitor_config {
    protocol = "http"
    port     = 80
    path     = "/"
  }
}

resource "azurerm_public_ip" "pip" {
  name                         = "ip${count.index}"
  location                     = "South Central US"
  resource_group_name          = "shuioracle"
  public_ip_address_allocation = "static"
  domain_name_label            = "shuilinux5${count.index}"
  count                        = "3"
}

resource "azurerm_traffic_manager_endpoint" "endpoint" {
  name                = "endpoint${count.index}"
  resource_group_name = "shuioracle"
  profile_name        = "${azurerm_traffic_manager_profile.profile.name}"
  target_resource_id  = "${element(azurerm_public_ip.pip.*.id, count.index)}"
  type                = "azureEndpoints"
  weight              = 1
  count               = "3"
}

在脚本中,将public_ip_address_allocation = "dynamic"修改为static

使用static,您的脚本就会成功。当您创建公共IP时,如果您使用动态,它将不会关联IP地址,如果您使用静态,它将关联IP。

您可以检查这个示例和这个示例

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47015326

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档