【发布时间】:2022-02-23 03:44:18
【问题描述】:
我在访问我的数据“terrafrom_remote_state”对象时遇到问题。
因此,我正在关注 hashcorp 站点,使用带有运行触发器的 terraform 云部署 azure 资源。触发器正在工作,正在运行第二个工作区的计划,但它无法访问我通过输出传递的数据。
我已将第一个工作区的“状态”设置为共享,并将第二个工作区的运行触发器设置为由第一个触发。这里没有问题。
我试图关注 hasicorp 网站上的内容,但它是针对 aws 的,所以可能是因为 azure 我错过了一些东西。我将发布我的输出,然后是第二个工作区的一些代码。
输出:我在状态文件中查看过,看起来不错。
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
}
}
错误是
错误:不支持的属性│ │ 在 main.tf 第 26 行,在资源中 “azurerm_public_ip”“pip1”:│26:位置= data.terraform_remote_state.network.outputs.location │
├──────────────── │ │ data.terraform_remote_state.network.outputs 是没有属性的对象│ │ 这个对象没有 名为“位置”的属性。
我无法访问 data.terraform_remote_state.network.outputs
【问题讨论】:
标签: azure terraform azure-rm terraform-cloud terraform-remote-state