Skip to content

Instantly share code, notes, and snippets.

@maravedi
Created September 14, 2023 13:37
Show Gist options
  • Save maravedi/69be8973beb0de9b732ecfed508cb015 to your computer and use it in GitHub Desktop.
Save maravedi/69be8973beb0de9b732ecfed508cb015 to your computer and use it in GitHub Desktop.
VScode Find and Replace Terraform Plan Output Grossness
// The idea behind this is that you can do a terraform plan -out test.tfplan and then take the output that's printed
// and copy/paste it into your code, then use these commands to clean it up so it's usable code.
// In newer versions of Terraform you can do a terraform plan -generate-config to do this a different way, so check that out too.
// Uses this exctension: https://marketplace.visualstudio.com/items?itemName=ArturoDent.find-and-transform&ssr=false#overview
"findInCurrentFile": {
"replaceHyphenPrefix": {
"title": "Replace Terraform Plan output hyphen prefix...", // will appear in the Command Palette
"find": "^(\\s+)- ",
"replace": "$1",
"isRegex": true,
"restrictFind": "selections", // default is entire document
},
"replaceNullSuffix": {
"title": "Replace Terraform Plan output -> null suffix...", // will appear in the Command Palette
"find": "\\s->\\snull$",
"replace": "",
"isRegex": true,
"restrictFind": "selections", // default is entire document
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment