mirror of
https://github.com/status-im/infra-utils.git
synced 2025-02-23 01:18:08 +00:00
Also ignore resources that are only created or only destroyed. Signed-off-by: Jakub Sokołowski <jakub@status.im>
31 lines
627 B
Awk
31 lines
627 B
Awk
# 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 = resource
|
|
if (new == "") {
|
|
next
|
|
}
|
|
}
|
|
if ($5 == "created") {
|
|
new = resource
|
|
if (new == "") {
|
|
next
|
|
}
|
|
}
|
|
if (old != "" && new != "") {
|
|
printf "terraform state mv '%s' '%s'\n", old, new
|
|
}
|
|
old = new = ""
|
|
}
|