Last active
October 28, 2016 04:40
-
-
Save petrabarus/367f58fa0b4deecdac7159d9af42dccf to your computer and use it in GitHub Desktop.
Get AWS Spot Instances using AWS CLI and execute command via SSH
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 | |
aws ec2 describe-spot-instance-requests | \ | |
jq -r '.SpotInstanceRequests | .[] | select(.LaunchSpecification.InstanceType == "c4.8xlarge" and .State == "active") | .InstanceId' | \ | |
xargs -I X sh -c "aws ec2 describe-instances --instance-id X | jq -r .Reservations[0].Instances[0].PublicDnsName" | \ | |
xargs -I X ssh -i ~/mykey.pem ubuntu@X "echo \"Hello WOrld\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment