gpt4 book ai didi

azure - 流量管理器的 Terraform 脚本抛出未知错误

转载 作者:行者123 更新时间:2023-12-03 04:22:53 26 4
gpt4 key购买 nike

我在部署流量管理器时遇到错误。这可能是非常基本的配置。但是,它显示“未知服务错误”,我不知道如何解决此问题。

Terraform Version

Terraform v0.10.0

# Service Principle

variable "subscription_id" {}

variable "client_id" {}

variable "client_secret" {}

variable "tenant_id" {}

Resource Group

变量“resource_group”{}

变量“位置”{}

变量“环境”{}

Actual script

  # 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"

Expected Behavior

It should be create a Traffic Manager Profile instance on Azure

Actual Behavior

Resource Group created but traffic manager profile throws error.

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

最佳答案

请使用以下脚本,它对我有用。

  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。

你可以检查这个example还有这个example .

关于azure - 流量管理器的 Terraform 脚本抛出未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47015326/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com