private static void resources(AmazonSQS sqs, String tasksUrl){
		int workers, oldQueue=0, queue=1;
		final int MAX_NUMBER_OF_WORKERS=32;
		
		//set up EC2
		AmazonEC2 ec2 = new AmazonEC2Client(new ClasspathPropertiesFileCredentialsProvider());
		Region usEast = Region.getRegion(Regions.US_EAST_1);
		ec2.setRegion(usEast);
		
		List <SpotInstanceRequest> instances=new ArrayList <SpotInstanceRequest>();
		
		//set up instance, it is a one time request
		RequestSpotInstancesRequest requestRequest = new RequestSpotInstancesRequest();
		requestRequest.setSpotPrice("0.15");
		requestRequest.setInstanceCount(Integer.valueOf(1));
		LaunchSpecification launchSpecification = new LaunchSpecification();
		launchSpecification.setImageId("ami-7a204313");
		launchSpecification.setInstanceType("m1.small");
		ArrayList<String> securityGroups = new ArrayList<String>();
		securityGroups.add("pa4");
		launchSpecification.setSecurityGroups(securityGroups);
		requestRequest.setLaunchSpecification(launchSpecification);
		
		//monitor queue, until queue==0 since we only put one file in tasks in this implementation
		while(queue>0){		
			try{
				//check each second
				Thread.sleep(1000);
				//check queue size
				GetQueueAttributesRequest qar = new GetQueueAttributesRequest(tasksUrl);
				qar.setAttributeNames( Arrays.asList("ApproximateNumberOfMessages"));
				queue=Integer.parseInt(sqs.getQueueAttributes(qar).getAttributes().get("ApproximateNumberOfMessages"));
				
				//if queue grows																							
				if(queue>oldQueue){
					//update oldQueue
					oldQueue=queue;
					//get number of machines
					workers=0;
					//iterate through all the instances we initiated
					for (SpotInstanceRequest req : instances){
						//get state
						String state=req.getState();
						//if its starting (open) or running (active) add to workers
						if(state.equals("open")||state.equals("active")){
							workers++;
						}else{
							//workers that were already terminated or weren't able to start are eliminated from list
							instances.remove(req);
						}
					}
					if(workers<MAX_NUMBER_OF_WORKERS){
						//request for instance	
						RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(requestRequest);
						//add new machine
						instances.addAll(requestResult.getSpotInstanceRequests());
					}

				}
			}catch(Exception e){
				e.printStackTrace();
			}
		}

	}