From 9932ca7ceadda1ae5b5a379092e744005f3f4b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 11 Jul 2022 15:23:06 +0200 Subject: [PATCH] terraform/rename.awk: simpler version of move.awk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- terraform/rename.awk | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 terraform/rename.awk diff --git a/terraform/rename.awk b/terraform/rename.awk new file mode 100644 index 0000000..552206d --- /dev/null +++ b/terraform/rename.awk @@ -0,0 +1,14 @@ +# Script for renaming Terraform resources when changing names. +# WARNING: Use '-no-color' flag when running 'terraform plan'. +/will be/{ + if ($5 == "updated") { + next + } + if ($5 == "created") { + new = $2 + } + if ($5 == "destroyed") { + old = $2 + printf "terraform state mv '%s' '%s'\n", old, new + } +}