#!/bin/bash

pem="/home/nick/Desktop/Amazon/ami-test/myAmiTestKey.pem"


	echo "about to create instance with image  	ami-ccf615a5"	
	instanceid=$( ec2-run-instances ami-ccf615a5 -k myAmiTestKey -z us-east-1a | egrep ^INSTANCE | cut --fields=2 );
	echo "instanceid=$instanceid";
	
	echo "instance created successfully and now wait for it being ready..."
	while host=$(ec2-describe-instances "$instanceid" | egrep ^INSTANCE | cut -f4) && test -z $host; do 
		echo -n .; 
		sleep 1; 
	done
	
	echo -e "\nThis is the host:$host";

	echo ssh -i $pem ubuntu@$host




