I am really not sure why I am seeing this error. I know it's something simple and right in my face . My issue is how I am passing on the subnet_id
in the subnet_mapping block. This is the code below:
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...
Terragrunt error
Error: Variables not allowed
on <value for var.subnet_id> line 1:
(source code not available)
Variables may not be used here.
I would appreciate some feedback. It has been a pain for the past few hours.
This error message is quite misleading, as evidenced by several people raising the issue on GitHub. In your case, the problem is that you have a variable named subnet_id
and you also use the same identifier in the inputs block (in subnet_id = dependency.test.outputs.public_subnet_ids[1]
). Renaming one of them should solve the issue.