newsapps / beeswithmachineguns

A utility for arming (creating) many bees (micro EC2 instances) to attack (load test) targets (web applications).
http://apps.chicagotribune.com/
MIT License
6.43k stars 631 forks source link

Imported key not used #171

Open mgla opened 7 years ago

mgla commented 7 years ago

There seems to be a problem with the usage of imported keys. I have tried my default keys, I have tried importing a new one. I have confirmed the key is imported. Maybe a problem with the boto usage?

beeswithmachineguns is up-to-date

$ pip install beeswithmachineguns --upgrade

Requirement already up-to-date: beeswithmachineguns in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: boto==2.0 in /usr/local/lib/python2.7/dist-packages (from beeswithmachineguns)
Requirement already up-to-date: paramiko==1.7.7.1 in /usr/local/lib/python2.7/dist-packages (from beeswithmachineguns)
Requirement already up-to-date: pycrypto>=2.1 in /usr/lib/python2.7/dist-packages (from paramiko==1.7.7.1->beeswithmachineguns)
Cleaning up...

The key is imported:

$ aws ec2  describe-key-pairs | grep  bee -A 1 -B 2
        {
            "KeyFingerprint": "04:b6:8a:f8:fc:37:fd:c1:d4:62:81:18:71:84:49:b8",
            "KeyName": "bee"
        },

My key file is indeed a valid private key.

$ file  ~/.ssh/bee.pem

/home/vagrant/.ssh/bee.pem: PEM RSA private key

bees fails with a rather cryptic error.

$ bees up -s 3  -k bee
New bees will use the "default" EC2 security group. Please note that port 22 (SSH) is not normally open on this group. You will need to use to the EC2 tools to open it before you will be able to attack.
Connecting to the hive.
Attempting to call up 3 bees.
Traceback (most recent call last):
  File "/usr/local/bin/bees", line 5, in <module>
    main.main()
  File "/usr/local/lib/python2.7/dist-packages/beeswithmachineguns/main.py", line 127, in main
    parse_options()
  File "/usr/local/lib/python2.7/dist-packages/beeswithmachineguns/main.py", line 111, in parse_options
    bees.up(options.servers, options.group, options.zone, options.instance, options.login, options.key)
  File "/usr/local/lib/python2.7/dist-packages/beeswithmachineguns/bees.py", line 104, in up
    placement=zone)
  File "/usr/local/lib/python2.7/dist-packages/boto/ec2/connection.py", line 618, in run_instances
    return self.get_object('RunInstances', params, Reservation, verb='POST')
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 699, in get_object
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidKeyPair.NotFound</Code><Message>The key pair 'bee' does not exist</Message></Error></Errors><RequestID>edd8dc4a-3b11-4524-a5e3-623085181f45</RequestID></Response>

I checked my .boto file as well. I assume this is at least a documentation issue.

mgla commented 7 years ago

After some more testing, I found out that the checked out development environment gives more meaningful errors. I did no select the correct region.

After specifying -z eu-west-1a, the error changed to "ami not found". Apperently, the regions.json file is ignored. Declaring the AMI as well helps.