-
-
Save corkupine/ac443a3d04cbfdedb2ad21950aaa2055 to your computer and use it in GitHub Desktop.
import terraform stack resources helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# List terraform resources in the current directory and ask their arn to import them into terraform state | |
RESOURCES_LIST=$(awk -F\" '/^resource "/ {print $2"."$4}' *.tf) | |
for resource in ${RESOURCES_LIST} | |
do | |
read -p "Enter ARN for resource ${resource} (type none to not import it): " arn | |
if [[ ${arn} != "none" ]] | |
then | |
terraform import ${resource} ${arn} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment