Add 'import_plan.sh'

master
silverwizard 4 years ago
parent ad5eec56fb
commit 55ed6475bc
  1. 10
      import_plan.sh

@ -0,0 +1,10 @@
#!/bin/sh
# This currently will only import aws_route53_records - and it will output the commands to be run
# Please only use this as a last resort
grep -A 100000 "Terraform will perform the following actions:" $1|grep -B 1000000 "Plan:"|sed 's/\e\[\d*(;\d+)*m//g'| \
awk \
'$1 == "+" && $2 ~ /aws_route53_record/ { active = 1; record = $2 };
$1 == "name:" { name = $2; };
$1 == "zone_id:" { id = $2; };
$1 == "type:" { type = $2; };
$0 == "" { if (active) print "terraform import " record " " id "_" name "_" type; active = 0; }'| sed 's/"//g'
Loading…
Cancel
Save