Last active
September 18, 2019 21:05
-
-
Save YakDriver/200f7b056685e872f58282ab513eddaa to your computer and use it in GitHub Desktop.
Helpful Visual Studio Code REGEXes to upgrade and clean up Terraform 0.12 config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assumptions: | |
- Terraform 0.12 tool has already been run | |
- Variables fields are in the order: type, description, default (if any) | |
--------------------------------------------- | |
BOOL | |
Transform 0.11 string booleans to native bool | |
--------------------------------------------- | |
Find:(type\s+=\s*)string(\n\s+description.*\n\s+default\s+=\s+)"(false|true)" | |
Replace:$1bool$2$3 | |
--------------------------------------------- | |
NULL | |
Convert default empty strings to null | |
--------------------------------------------- | |
Find:(type\s+=\s*string\n\s+description.*\n\s+default\s+=\s+)"" | |
Replace:$1null | |
--------------------------------------------- | |
Add Optional to Variable descriptions | |
--------------------------------------------- | |
Find:(description\s+=\s")([a-z].*\n\s+default) | |
Replace:$1(Optional) $2 | |
--------------------------------------------- | |
Add Required to Variable descriptions | |
--------------------------------------------- | |
Find:(description\s+=\s")([a-z0-9].*\n\s*\}) | |
Replace:$1(Required) $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note, this upgrades to native bools after the upgrade tool has run, which leaves bools as strings.