Terraform 计划停留在 ADO 管道中的 Terraform:Plan 任务
Terraform Plan stuck at Terraform:Plan task in ADO pipeline
我正在尝试按照以下 link 通过 Azure Dev Ops Pipeline 使用 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”步骤卡在发布管道中,如屏幕截图所示。
知道为什么会发生这种情况并且计划没有正确完成
我已禁用 Terraform Init 并启用调试。但它仍然在 Terraform Apply 失败,我看到了以下日志。任务永远不会完成
Terraform 应用任务
Exit code 0 received from tool 'C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe'
STDIO streams have closed for tool 'C:\hostedtoolcache\windows\terraform.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.5\x64\terraform.exe'
which 'C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe'
found: 'C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe'
C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe arg: apply
C:\hostedtoolcache\windows\terraform.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.5\x64\terraform.exe
arguments:
当 运行 Terraform 来自 non-interactive 管道时,您必须添加标志 -input=false
,否则 Terraform 将在等待用户输入时挂起。
在此处查看文档:https://www.terraform.io/cli/commands/plan#input-false
我的地形文件如下:
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”步骤卡在发布管道中,如屏幕截图所示。 知道为什么会发生这种情况并且计划没有正确完成
我已禁用 Terraform Init 并启用调试。但它仍然在 Terraform Apply 失败,我看到了以下日志。任务永远不会完成
Terraform 应用任务
Exit code 0 received from tool 'C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe'
STDIO streams have closed for tool 'C:\hostedtoolcache\windows\terraform.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.5\x64\terraform.exe'
which 'C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe'
found: 'C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe'
C:\hostedtoolcache\windows\terraform.1.5\x64\terraform.exe arg: apply
C:\hostedtoolcache\windows\terraform.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.5\x64\terraform.exe
arguments:
当 运行 Terraform 来自 non-interactive 管道时,您必须添加标志 -input=false
,否则 Terraform 将在等待用户输入时挂起。
在此处查看文档:https://www.terraform.io/cli/commands/plan#input-false