diff --git a/README.md b/README.md index 44f2ad3..3b0dc2e 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ The ["I am starting from scratch" quick-start guide](<2.2. I am starting from sc 2. [Reusable root modules]() 3. [Jinja templating for Terraform]() 4. [Jinja templating for variables]() - 5. [Remote lookup functions]() + 5. [Custom Jinja functions]() 6. [Inline secret encryption]() 7. [Automatic variable initialization]() 2. Features you can build with Stacks diff --git a/docs/3.1.5. Remote lookup functions.md b/docs/3.1.5. Custom Jinja functions.md similarity index 63% rename from docs/3.1.5. Remote lookup functions.md rename to docs/3.1.5. Custom Jinja functions.md index 4c28811..464220d 100644 --- a/docs/3.1.5. Remote lookup functions.md +++ b/docs/3.1.5. Custom Jinja functions.md @@ -1,9 +1,9 @@ -# Remote lookup functions +# Custom Jinja functions With Jinja you get to inject your own custom functions to be used in templating, so of course we do. -## The `variable` lookup function -With the `variable` lookup function you can fetch any variable value off any other layer in your repository. +## The `variable` function +With the `variable` function you can fetch any variable value off any other layer in your repository. ### Example 1: fetching a `vpc_id` variable from the same layer in a different stack ```hcl # stacks/ec2/stack.tfvars.jinja: @@ -20,18 +20,26 @@ vpc_id = "{{ variable("vpc_id", stack="vpc", environment="production") }}" vpc_id = "{{ variable("vpc_id", stack="vpc", environment="development", subenvironment="us-east-1", instance="foo") }}" # stack/environment/subenvironment/instance all default to the caller's ``` -## The `output` lookup function -With the `output` lookup function you can fetch any output value off the state of any other layer in your repository. +## The `output` function +With the `output` function you can fetch any output value off the state of any other layer in your repository. ### Example 1: fetching a `vpc_id` output from the same layer in a different stack ```hcl # stacks/ec2/stack.tfvars.jinja: vpc_id = "{{ output("vpc_id", stack="vpc") }}" ``` -## The `resource` lookup function -With the `resource` lookup function you can fetch any resource attributes off the state of any other layer in your repository. +## The `resource` function +With the `resource` function you can fetch any resource attributes off the state of any other layer in your repository. ### Example 1: fetching a `aws_vpc.main` resource from the same layer in a different stack ```hcl # stacks/ec2/stack.tfvars.jinja: vpc_id = "{{ resource("aws_vpc.main", stack="vpc")["id"] }}" ``` + +## The `md5`, `sha1`, `sha256` and `sha512` functions +With these functions you can generate the MD5, SHA-1, SHA-256 and SHA-512 checksums respectively of a given string. +### Example +```hcl +# stacks/ec2/stacks.tfvars.jinja +foo_md5 = "{{ md5("foo") }}" +```