This will create the cheapest possible EC2 instance for
- running the fetchBot, or
- just playing around.
- Create an EC2 key pair
- Install ansible
- Set up boto
- Create an EC2 instance
- List all EC2 instances
- Terminate all EC2 instances
- FAQ
$ sudo apt-get update
$ sudo apt-get install jq
$ aws ec2 create-key-pair --key-name ghuser | jq -r '.KeyMaterial' > secret.pem
$ chmod 600 secret.pem
$ sudo -H pip3.5 install ansible boto boto3
...
Successfully installed ansible-2.6.1 boto-2.49.0 boto3-1.7.56 botocore-1.10.56 [...]
$ sed s/default/Credentials/g ~/.aws/credentials > ~/.boto
$ ./ansible-playbook.sh create.yml
$ ./ansible-inventory.sh --list | jq -r '.ec2'
{
"hosts": [
"18.207.151.144"
]
}
$ ./ansible-playbook.sh terminate.yml
e.g.
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x788849d5eae8>
Traceback (most recent call last):
File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
This is a Python bug, see ansible#21982.