diff --git a/import_plan.sh b/import_plan.sh new file mode 100644 index 0000000..6e735be --- /dev/null +++ b/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' \ No newline at end of file