gpt4 book ai didi

azure - Terraform 计划卡在 Terraform :Plan task in ADO pipeline

转载 作者:行者123 更新时间:2023-12-02 23:12:45 25 4
gpt4 key购买 nike

enter image description here我尝试按照以下链接通过 Azure Dev Ops Pipeline 使用 Terraform 部署应用程序服务

AzureDevOpsLabs

我的 terraform 文件如下:

webapp.tf

terraform {
required_version = "~> 1.0"
backend "azurerm" {
storage_account_name = "__terraformstorageaccount__"
container_name = "terraform"
key = "terraform.tfstate"
}
}

provider "azurerm" {
tenant_id = var.tenant_id
client_id = var.client_id
client_secret = var.client_secret
subscription_id = var.subscription_id
features {}
}

resource "azurerm_resource_group" "dev" {
name = var.resource_group_name
location = var.resource_group_location
}

resource "azurerm_app_service_plan" "dev" {
name = var.appserviceplan
location = var.resource_group_location
resource_group_name = var.resource_group_name

sku {
tier = "Free"
size = "F1"
}
depends_on = [
azurerm_resource_group.dev
]
}

resource "azurerm_app_service" "dev" {
name = var.appservicename
location = azurerm_app_service_plan.dev.location
resource_group_name = azurerm_app_service_plan.dev.location
app_service_plan_id = azurerm_app_service_plan.dev.id
}

var.tf

variable "client_id" {}

variable "client_secret" {}

variable "tenant_id" {}

variable "subscription_id" {}

variable "appserviceplan" {}

variable "appservicename" {}

variable "resource_group_name" {}

variable "resource_group_location" {}

实际值在管道变量中给出

我直接使用开源 terraform 部署了相同的应用程序服务,并且运行良好。

但是“Terraform:Plan”步骤卡在发布管道中,如屏幕截图所示。知道为什么会发生这种情况并且计划没有正确完成

enter image description here

我已禁用 Terraform Init 并启用调试。但它在 Terraform Apply 时仍然失败,我看到以下日志。任务永远不会完成

Terraform 应用任务

Exit code 0 received from tool 'C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe'
STDIO streams have closed for tool 'C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe'
provider=azurerm
commandOptions=-auto-approve
workingDirectory=C:\hostedtoolcache\windows\terraform
environmentServiceNameAzureRM=a8ee372e-0734-4e50-aa5a-e19d9e5f2a62
which 'terraform'
found: 'C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe'
which 'C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe'
found: 'C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe'
C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe arg: apply
C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe arg: -auto-approve
a8ee372e-0734-4e50-aa5a-e19d9e5f2a62 auth param serviceprincipalid = ***
a8ee372e-0734-4e50-aa5a-e19d9e5f2a62 auth param serviceprincipalkey = ***
a8ee372e-0734-4e50-aa5a-e19d9e5f2a62 data subscriptionid = xxxx-xxxx-xxxx
a8ee372e-0734-4e50-aa5a-e19d9e5f2a62 auth param tenantid = xxxx-xxxxxx
a8ee372e-0734-4e50-aa5a-e19d9e5f2a62 auth param serviceprincipalid = ***
a8ee372e-0734-4e50-aa5a-e19d9e5f2a62 auth param serviceprincipalkey = ***
exec tool: C:\hostedtoolcache\windows\terraform\1.1.5\x64\terraform.exe
arguments:

最佳答案

从非交互式管道中运行 Terraform 时,您必须添加标志 -input=false ,否则 Terraform 将挂起等待用户输入。

请参阅此处的文档:https://www.terraform.io/cli/commands/plan#input-false

关于azure - Terraform 计划卡在 Terraform :Plan task in ADO pipeline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71680143/

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