【发布时间】:2022-11-19 09:27:48
【问题描述】:
我真的不确定为什么会看到这个错误。我知道这是简单而正确的事情。我的问题是我如何传递 subnet_mapping 块中的 subnet_id。这是下面的代码:
main.tf
resource "aws_lb" "lb" {
name = var.name
internal = var.internal
load_balancer_type = var.lb_type
enable_cross_zone_load_balancing = var.enable_cross_zone_load_balancing
subnet_mapping {
allocation_id = aws_eip.lb.id
subnet_id = var.subnet_id[1]
}
}
resource "aws_eip" "lb" {
vpc = true
}
variables.tf
variable "name" {
type = string
}
variable "internal" {
type = bool
default = false
}
variable "lb_type" {
type = string
default = "network"
}
variable "enable_cross_zone_load_balancing" {
type = bool
default = true
}
variable "vpc" {
type = bool
default = true
}
variable "vpc_id" {
type = string
}
variable "subnet_id" {
type = list(string)
default = []
}
terragrunt.hcl
include {
path = find_in_parent_folders()
}
dependency "test" {
config_path = "../../../folder/test"
mock_outputs = {
vpc_id = "vpc-12345"
public_subnet_ids = ["subnet-1", "subnet-2"]
}
}
# var to pass in to use the module specified in the terragrunt configuration above
inputs = {
vpc_id = dependency.test.outputs.vpc_id
subnet_id = dependency.test.outputs.public_subnet_ids[1]
xxx...
错误
Error: Variables not allowed
on <value for var.subnet_id> line 1:
(source code not available)
Variables may not be used here.
我会很感激一些反馈。过去几个小时一直很痛。
【问题讨论】:
标签: terraform terragrunt