mirror of
https://github.com/status-im/infra-utils.git
synced 2025-02-22 08:58:19 +00:00
terraform/rename.awk: fix to ignore order of lines
Also ignore resources that are only created or only destroyed. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
fb3f174c5b
commit
e1244169a3
@ -1,15 +1,30 @@
|
||||
# Script for renaming Terraform resources when changing names.
|
||||
# WARNING: Use '-no-color' flag when running 'terraform plan'.
|
||||
BEGIN{
|
||||
old = new = ""
|
||||
}
|
||||
/will be/{
|
||||
resource = $2
|
||||
if (resource ~ "cloudflare_record") {
|
||||
next
|
||||
}
|
||||
if ($5 == "updated") {
|
||||
next
|
||||
}
|
||||
if ($5 == "destroyed") {
|
||||
old = $2
|
||||
next
|
||||
old = resource
|
||||
if (new == "") {
|
||||
next
|
||||
}
|
||||
}
|
||||
if ($5 == "created") {
|
||||
new = $2
|
||||
new = resource
|
||||
if (new == "") {
|
||||
next
|
||||
}
|
||||
}
|
||||
printf "terraform state mv '%s' '%s'\n", old, new
|
||||
if (old != "" && new != "") {
|
||||
printf "terraform state mv '%s' '%s'\n", old, new
|
||||
}
|
||||
old = new = ""
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user