Skip to content

Instantly share code, notes, and snippets.

@minhoryang
Forked from pahud/build_dm_awsec2.sh
Last active August 12, 2017 07:32
Show Gist options
  • Save minhoryang/f070a82f622b8a885dbb92e45ba21b55 to your computer and use it in GitHub Desktop.
Save minhoryang/f070a82f622b8a885dbb92e45ba21b55 to your computer and use it in GitHub Desktop.
build your docker-machine on AWS EC2 instance
#!/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
@minhoryang
Copy link
Author

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