Skip to content
This repository was archived by the owner on Jun 14, 2020. It is now read-only.

Latest commit

 

History

History

ec2

This will create the cheapest possible EC2 instance for

  • running the fetchBot, or
  • just playing around.

Table of Contents

Create an EC2 key pair

$ 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

Install ansible

$ 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 [...]

Set up boto

$ sed s/default/Credentials/g ~/.aws/credentials > ~/.boto

Create an EC2 instance

$ ./ansible-playbook.sh create.yml

List all EC2 instances

$ ./ansible-inventory.sh --list | jq -r '.ec2'
{
  "hosts": [
    "18.207.151.144"
  ]
}

Terminate all EC2 instances

$ ./ansible-playbook.sh terminate.yml

FAQ

Sometimes the playbook ends with Exception ignored

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.