Table of contents
This repository contains examples that relate to, and extend on, my Medium Blog Post - A better way of using AFT in a multi-region CT Landing Zone.
Although this is detailed in my blog post, here is the command that AFT runs in order to turn Jinja files into Terraform -
for f in *.jinja; do jinja2 $f -D timestamp="$TIMESTAMP" -D tf_distribution_type=$TF_DISTRIBUTION -D provider_region=$CT_MGMT_REGION -D region=$TF_BACKEND_REGION -D aft_admin_role_arn=$AFT_EXEC_ROLE_ARN -D target_admin_role_arn=$VENDED_EXEC_ROLE_ARN -D bucket=$TF_S3_BUCKET -D key=$TF_S3_KEY -D dynamodb_table=$TF_DDB_TABLE -D kms_key_id=$TF_KMS_KEY_ID >> ./$(basename $f .jinja).tf; done
To use this locally, cd
into the directory containing your Jinja Templates and run the command from within there. I suggest changing the variables (e.g "$TIMESTAMP"
) into simply strings of themselves as this allows for easy use and tracking of where the variables will end up. I also suggest creating a tmp
directory and editing the final part of the command to put the newly created Terraform in that new tmp
directory (./$(basename $f .jinja).tf
becomes ./tmp/$(basename $f .jinja).tf
) as this allows for easy clean up with rm -rf tmp
.
I have included and example of what the produced Terraform looks like in the blog_post_example and module_example directories.
I am sure the examples in this repository are nowhere near exhaustive. If you come up with another use case or example you would like to share to others please do not hesitate to do so. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Example Branch (
git checkout -b example/new_example
) CD
Into theexamples
Directory and Create a New Directory for your Example- Work your Magic 🧙
- Commit your Changes (
git commit -m 'Added an Example'
) - Push to the Branch (
git push origin example/new_example
) - Open a Pull Request and detail your new Example!
Distributed under the MIT License. See LICENSE.txt
for more information.