Skip to content

pattisoj/aft-multi-region-ct-landing-zone-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

A better way of using AFT in a multi-region CT Landing Zone

Blog Post Badge Stars MIT License

Table of contents
  1. About The Repository
  2. Contributing
  3. License
  4. Contact

About The Repository

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.

Contributing

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.

  1. Fork the Project
  2. Create your Example Branch (git checkout -b example/new_example)
  3. CD Into the examples Directory and Create a New Directory for your Example
  4. Work your Magic 🧙
  5. Commit your Changes (git commit -m 'Added an Example')
  6. Push to the Branch (git push origin example/new_example)
  7. Open a Pull Request and detail your new Example!

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Twitter Linkedin

(Back to top)

About

Examples of how to use AFT in a multi-region CT Landing Zone

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published