WaspsWithBazookas icon indicating copy to clipboard operation
WaspsWithBazookas copied to clipboard

Unable to used AWS location

Open NeckBeardPrince opened this issue 5 years ago • 3 comments

$ wwb-cli spawn aws -w 2 Invalid command: See --help for a list of available commands.

NeckBeardPrince avatar Jul 17 '19 17:07 NeckBeardPrince

That command does not work yet, if your interested in helping contributing to adding this functionality that would be cool. aws cli code

How we currently do it is we made an aws instance that has a wasp running on it on startup (spin up as many as you want) and also one instance running the hive.

This is the bash script I wrote to start the hive for some sample code

#!/bin/bash
instance="i-1231231234"
aws-mfa
if [[ $(aws ec2 describe-instances --instance-ids $instance --query 'Reservations[].Instances[].State[].Name' --output text) = "running" ]] ; then \
    echo "Instance already started"; \
    elif [[ $(aws ec2 describe-instances --instance-ids $instance --query 'Reservations[].Instances[].State[].Name' --output text) = "stopped" ]] ; then \
    echo "Starting instance.." && aws ec2 start-instances --instance-ids $instance && aws ec2 wait instance-running --instance-ids $instance &&  echo "Instance started!"; \
    fi

ec2ip=$(aws ec2 describe-instances --instance-ids $instance --query 'Reservations[*].Instances[*].PrivateIpAddress' --output text)
echo $ec2ip
echo "Saving WWB config.."
echo '{"instance":{"type":"remote","hive":{"ip":"'$ec2ip'","port":"4269","pid":null},"wasp":{"ip":"0.0.0.0"}},"wasps":[]}' > ${BASH_SOURCE%/*}/../config.json
echo "WWB config saved"
wwb-cli hive status --config ${BASH_SOURCE%/*}/../config.json

Phara0h avatar Jul 30 '19 19:07 Phara0h

I decided I would start working on this, along with making the SDK. Stay tuned for its completion.

Phara0h avatar Aug 06 '19 23:08 Phara0h

@NeckBeardPrince https://github.com/Phara0h/wwb-sdk Just pushed up the first WIP of the wwb-sdk that includes the spawning stuff you wanted. Here is how you use it.

const SDK = require('wwb-sdk');
const sdk = new SDK({path:require('path').resolve('./config/config.json')});

async function test()
{
  await sdk.Spawn.Aws.createSecurityGroup();
  await sdk.Spawn.Aws.createHiveInstance();
  await sdk.Spawn.Aws.createWaspsInstances(2);

  await sdk.Spawn.Aws.stopHiveInstance();
  await sdk.Spawn.Aws.stopWaspsInstances();

  await sdk.Spawn.Aws.startHiveInstance();
  await sdk.Spawn.Aws.startWaspsInstances();

  await sdk.Spawn.Aws.destoryHiveInstance();
  await sdk.Spawn.Aws.destoryWaspsInstances();
}

test();

Feel free to use this to just make a quick script to create the hive and as many wasps as you want. However, you could wait for me to refactor the wwb-cli to use the wwb-sdk and then not need to do this. Hope this helps

Phara0h avatar Aug 07 '19 00:08 Phara0h