public BeansTalkDeployer(
      String accessKey, String secretKey, String applicationName, String environmentName) {

    this.accessKey = accessKey;
    this.secretKey = secretKey;

    this.applicationName = applicationName;
    this.environmentName = environmentName;

    elasticBeanstalk = getBeansTalkClient();

    elasticBeanstalk.setEndpoint(DEFAULT_ENDPOINT);
  }
  @Override
  public void deploy(File appWarFile) {

    log.info("Finding S3 bucket to upload WAR");

    String bucketName = elasticBeanstalk.createStorageLocation().getS3Bucket();

    String s3key = uniqueTempWarFileName(appWarFile);
    uploadToS3(appWarFile, bucketName, s3key);

    String versionLabel = getVersionLabel(appWarFile);

    log.info("Create application version with uploaded application");

    CreateApplicationVersionRequest cavr = new CreateApplicationVersionRequest();
    cavr.setApplicationName(applicationName);
    cavr.setVersionLabel(versionLabel);
    cavr.setDescription(getDescription());
    cavr.setAutoCreateApplication(true);
    cavr.setSourceBundle(new S3Location(bucketName, s3key));

    CreateApplicationVersionResult result;
    result = elasticBeanstalk.createApplicationVersion(cavr);

    log.info("Created application version {}", result);

    log.info("Updating environment with uploaded application version");

    UpdateEnvironmentRequest uer;
    uer = new UpdateEnvironmentRequest();

    uer.setEnvironmentName(environmentName);
    uer.setVersionLabel(versionLabel);

    UpdateEnvironmentResult result2;
    result2 = elasticBeanstalk.updateEnvironment(uer);

    log.info("Updated environment {}", result2);
  }
 @Override
 public void debug() {
   System.out.println(elasticBeanstalk.describeApplications());
   System.out.println(elasticBeanstalk.describeApplicationVersions());
   System.out.println(elasticBeanstalk.describeEnvironments());
 }