-
-
Save minhoryang/f070a82f622b8a885dbb92e45ba21b55 to your computer and use it in GitHub Desktop.
build your docker-machine on AWS EC2 instance
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
#!/bin/bash | |
machine=$(python -c "import uuid;print(uuid.uuid4())") | |
# NEEDED: AmazonEC2FullAccess, AmazonEC2SpotFleetRole | |
AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id) | |
AWS_DEFAULT_REGION=$(aws configure get region) | |
AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key) | |
VPC=$(aws ec2 describe-vpcs | jq -r '.Vpcs[0].VpcId') | |
echo "https://$AWS_DEFAULT_REGION.console.aws.amazon.com/ec2sp/v1/spot/dashboard" | |
docker-machine create --driver amazonec2 \ | |
--amazonec2-region ${AWS_DEFAULT_REGION} \ | |
--amazonec2-vpc-id ${VPC:-""} \ | |
--amazonec2-request-spot-instance \ | |
--amazonec2-block-duration-minutes 60 \ | |
--amazonec2-instance-type r4.large \ | |
--amazonec2-access-key ${AWS_ACCESS_KEY_ID} \ | |
--amazonec2-secret-key ${AWS_SECRET_ACCESS_KEY} \ | |
$machine |
aws ec2 describe-spot-price-history --start-time $(python -c "from datetime import *;print((datetime.today()-timedelta(minutes=30)).isoformat())") --product-description Linux/UNIX --instance-types r4.large c4.large i3.large r3.large m4.large
aws ec2 describe-instances | jq '.Reservations[].Instances[] | {PublicDnsName, State, LaunchTime}'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
eval $(docker-machine env $machine)
docker run -t -i -v /opt:$(pwd) buildpack-deps:xenial