Created
March 9, 2018 09:40
-
-
Save jmlrt/308e0811c52ff80d2ab9db1969154837 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