Last active
August 29, 2015 14:12
-
-
Save toshihirock/19b306c6f65d5b63ee9e to your computer and use it in GitHub Desktop.
EC2のリストを取得する
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
@Grapes([ | |
@Grab(group='commons-codec', module='commons-codec', version='1.10'), | |
@Grab(group='com.amazonaws', module='aws-java-sdk', version='1.9.13') | |
]) | |
import com.amazonaws.services.ec2.* | |
import com.amazonaws.auth.* | |
import com.amazonaws.auth.profile.* | |
import com.amazonaws.regions.* | |
credentials = new ProfileCredentialsProvider().getCredentials() | |
ec2 = new AmazonEC2Client(credentials) | |
ec2.setRegion(Region.getRegion(Regions.AP_NORTHEAST_1)) | |
result = ec2.describeInstances() | |
result.reservations.instances.each { | |
println "${it.tags[0].value[0]}\t${it.state.name[0]}\t${it.publicDnsName[0]}" | |
} |
Author
toshihirock
commented
Dec 27, 2014
- ~/.ssh/configにログイン対象のユーザー名、KeyPair、ホスト名を指定しておくこと
- ~/.aws/credentialsの設定をしておくこと
- groovy ec2list.groovy| percol | cut -f 3 | xargs -o -n 1 ssh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment