使用Azure的Terraform云运行触发器



我在访问数据时遇到问题"CCD_ 1";对象。。因此,我关注hashicorp网站,使用带有运行触发器的地形云部署azure资源。触发器正在运行,正在运行第二个工作区的计划,但它无法访问我通过输出传递的数据。

我已经设置了";状态";并将第二工作空间上的运行触发器设置为由第一工作空间触发。这里没有问题。

我试着关注hasicorp网站上的内容,但这是为了aws,所以,也许是为了azure,我错过了一些东西。我将发布我的输出,然后发布第二个工作区的一些代码。

Ouputs:我在状态文件中看过,看起来不错。

output "rgName" {
description = "The resource group for resources"
value = var.rgName
}
output "location" {
description = "The location for resources"
value = var.location
}
output "subnet1_id" {
description = "subnet 1"
value = azurerm_subnet.subnet1.id
}

第二工作区

data "terraform_remote_state" "network" {
backend = "remote"
config = {
organization = "Awesome-Company"
workspaces = {
name = "TFCloud-Trigger-Network"
}
}
}
provider "azurerm" {
version =  "2.66.0"
subscription_id = var.subscription_id
client_id = var.client_id
client_secret = var.clientSecret
tenant_id = var.tenant_id
features{}
}
#Deploy Public IP
resource "azurerm_public_ip" "pip1" {
name                = "TFC-pip1"
location            = data.terraform_remote_state.network.outputs.location
resource_group_name = data.terraform_remote_state.network.outputs.rgName  
allocation_method   = "Dynamic"
sku                 = "Basic"
}
#Create NIC
resource "azurerm_network_interface" "nic1" {
name                = "TFC-TestVM-Nic"  
location            = data.terraform_remote_state.network.outputs.location  
resource_group_name = data.terraform_remote_state.network.outputs.rgName 
ip_configuration {
name                          = "ipconfig1"
subnet_id                     = date.terraform_remote_state.network.outputs.subnet1_id 
private_ip_address_allocation  = "Dynamic"
public_ip_address_id          = azurerm_public_ip.pip1.id
}
}

错误为

错误:不支持的属性│ │在主.tf第26行,在资源中"azurerm_public_ip"pip1":│26:位置=数据.terraform_remote_state.network.outputs.location│
├──────────────── │ │数据.terraform_remote_state.network.outputs是没有属性的对象│ │此对象没有名为"的属性;位置";。

我无法访问数据.terraform_remote_state.network.outputs

所以,我发现了这一点,它不在文档中。由另一个工作区触发的工作区不会自动更新其地形平面。

通常,当我在github(或另一个repo(中编辑代码时,一旦保存了新代码,terraform云就会自动运行计划。由另一个工作区触发的工作区不会执行此操作。因此,即使我更改了代码,我也必须手动转到TFCloud,放弃在触发的工作区上的当前运行,并重新运行计划。在此之后,run触发器将成功运行。

这是一件奇怪的事情。。。

最新更新