With Jinja you get to inject your own custom functions to be used in templating, so of course we do.
With the variable function you can fetch any variable value off any other layer in your repository.
# stacks/ec2/stack.tfvars.jinja:
vpc_id = "{{ variable("vpc_id", stack="vpc") }}"# stacks/ec2/layers/development/layer.tfvars.jinja:
vpc_id = "{{ variable("vpc_id", stack="vpc", environment="production") }}"# stacks/ec2/layers/development@us-east-1_foo/layer.tfvars.jinja:
vpc_id = "{{ variable("vpc_id", stack="vpc", environment="development", subenvironment="us-east-1", instance="foo") }}" # stack/environment/subenvironment/instance all default to the caller'sWith the output function you can fetch any output value off the state of any other layer in your repository.
# stacks/ec2/stack.tfvars.jinja:
vpc_id = "{{ output("vpc_id", stack="vpc") }}"With the resource function you can fetch any resource attributes off the state of any other layer in your repository.
# stacks/ec2/stack.tfvars.jinja:
vpc_id = "{{ resource("aws_vpc.main", stack="vpc")["id"] }}"With these functions you can generate the MD5, SHA-1, SHA-256 and SHA-512 checksums respectively of a given string.
# stacks/ec2/stacks.tfvars.jinja
foo_md5 = "{{ md5("foo") }}"