Skip to content

Instantly share code, notes, and snippets.

@mrballcb
Last active April 25, 2020 18:01
Show Gist options
  • Save mrballcb/507db8d740832500b57c312aa326057b to your computer and use it in GitHub Desktop.
Save mrballcb/507db8d740832500b57c312aa326057b to your computer and use it in GitHub Desktop.
vim macros to convert TF 0.11 -> 0.12
When your TF is already partially TF12 and the TF11->12 converter barfs on it.
Regex anchors on beginning of line, so any commented config won't be adjusted.
## remove quotes from variable and provider and output lines
:%s/^\(variable\|provider\|output\) "\(\S*\)"/\1 \2/
## remove quotes from resource and data lines
:%s/^\(resource\|data\) "\(\S*\)" "\(\S*\)"/\1 \2 \3/
## remove quotes from type=$TYPE lines, preserving leading spacing
:%s/^\(\s*type\s*=\)\s*"\(\S*\)"/\1 \2/
## remove quotes from provider=$PROVIDER lines, preserving all spacing
:%s/^\(\s*provider\s*=\s*\)"\(\S*\)"/\1\2/
## convert "tags {" to "tags = {"
:%s/tags {/tags = {/
More will be added as I come across the need for them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment