Skip to content

Generate editor snippets based on Terraform provider schemas

Notifications You must be signed in to change notification settings

staticaland/terraform-generate-snippets

Repository files navigation

terraform-generate-snippets

The source of yasnippet-terraform.

This script generates YASnippet snippets based on Terraform provider schemas. It works by parsing terraform providers schema -json and creates snippet files based on the JSON.

generate_snippets.py make_provider_dirs looks up all the providers from the Terraform registry API and creates folders and Terraform files for all of them (every Terraform file in the providers directory).

Once you have a bunch of provider folders, generate_snippets.py generate_snippets will loop through all of them and run terraform providers schema -json (and terraform init if needed). It will take quite a lot of disk space and time to do the initial run. Subsequent runs should be fast as the latest schema version is saved to disk.

It should be fairly trivial to extend this to support multiple snippet systems.

Flow

generate_snippets.py -h

usage: generate_snippets.py [-h] {generate_snippets,make_provider_dirs} ...

positional arguments:
  {generate_snippets,make_provider_dirs}

optional arguments:
  -h, --help            show this help message and exit

Other

Snippet documentation for various editors:

About

Generate editor snippets based on Terraform provider schemas

Resources

Stars

Watchers

Forks