Profile picture
Nathan Handler @nathanhandler
, 4 tweets, 2 min read Read on Twitter
A common pattern that emerges when using @HashiCorp #Terraform is to have many types of policies inlined using a heredoc. This is frustrating as it means you can't use standard tools to validate and/or format these JSON policies.
gist.github.com/nhandler/97f55… is my attempt at a solution to this problem. All of your policies get defined as standalone JSON files within a templates/ directory. This makes it easy to copy from other tools (or even web consoles) and validate/format the contents.
A template_file is used to facilitate the use of variables, which are a great way to avoid ending up with magic numbers or hardcoded values in your policies. And a list of filenames is used to avoid having to declare multiple template_files and duplicate the list of variables.
Finally, access to the policy is keyed on the template filename, making it immediately clear which policy is being used and making the order of the list of filenames irrelevant. As a bonus, this approach significantly shrinks the size of your Terraform files.
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Nathan Handler
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member and get exclusive features!

Premium member ($3.00/month or $30.00/year)

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!