Created
February 6, 2017 00:58
-
-
Save joshlove/d7e9abb0881971e815651c95d52bf4f3 to your computer and use it in GitHub Desktop.
Import EC2 instances into terraform
This file contains hidden or 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 | |
| IFS=$'\n' | |
| for each in $(aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`].Value | [0]]' --output text); | |
| do | |
| instance=$(echo $each | cut -d$'\t' -f1) | |
| name=$(echo $each | cut -d$'\t' -f2) | |
| terraform import aws_instance.${name} ${instance} | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment