Skip to main content
Knowledge Base

output dependency not being read by input

Answer

Hi folks, I have a `security group` module that has the below output ``` output "id" { value = aws_security_group.main.id } ``` when i run `terragrunt output ` against the `security group` module it returns the following output value ``` arn = "arn:aws:ec2:eu-west-2:83160456789:security-group/sg-095f26bc2025abcde" id = "sg-095f26bc2025abcde" ``` however, when i try to call the above output in my `rds` module using a dependency in my terragrunt.hcl file, i get the following ``` │ Error: Variables not allowed │ │ on <value for var.vpc_security_group_ids> line 1: │ (source code not available) │ │ Variables may not be used here. ``` the variable in my `rds` module is setup as follows ``` variable "vpc_security_group_ids" { description = "List of VPC security groups to associate" type = list(string) default = [] } ``` my `terragrunt.hcl` file is setup as follows. Please note that i have been able to pass the hard coded security group value (commented out below) and get it to deploy successfully, but as soon as i attempt to use the `dependency.sg.outputs.id` it fails with the above error. For the record, i have tried wrapping it as `["dependency.sg.outputs.id"]` but this is then read in as a string and not a dynamic value. ``` dependency "sg" { config_path = "../sg/rds" } dependency "subnet" { config_path = "../subnet/mft-subnet" } inputs = { # vpc_security_group_ids = ["sg-095f26bc2025abcde"] vpc_security_group_ids = dependency.sg.outputs.id subnet_ids = dependency.subnet.outputs.aws_subnets.main.ids ``` **Any idea of what may be causing this???????** For the record, the `subnet_ids` in the **above** example in contrast works fine. It's output and variable are defined **below** for reference purposes only: ``` aws_subnets = { "main" = { "ids" = [ "subnet-02132b73acfeabcderr", "subnet-050d63659cd5abcdedf", ] } } module = {} variable "subnet_ids" { description = "A list of VPC subnet IDs" type = list(string) default = [] } ``` --- <ins datetime="2023-06-15T10:04:53Z"> <p><a href="https://support.gruntwork.io/hc/requests/110257">Tracked in ticket #110257</a></p> </ins>

Hi, the variable can be wrapped in `[]` to convert it to a list... ``` inputs = { vpc_security_group_ids = [ dependency.dep.outputs.id ] } ``` Simplified example in: https://github.com/denis256/terragrunt-tests/tree/master/discussion-738