com.amazonaws.services.elasticbeanstalk.model.CreateEnvironmentRequest Java Examples

The following examples show how to use com.amazonaws.services.elasticbeanstalk.model.CreateEnvironmentRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanstalkConnector.java    From cloudml with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void createEnvironment(String applicationName, String domainName, String envName, String stackName) {
    CreateEnvironmentRequest cr = new CreateEnvironmentRequest();
    cr.setApplicationName(applicationName);
    cr.setEnvironmentName(envName);
    String stack = findSolutionStack(stackName);
    if (!stack.equals("")) {
        cr.setSolutionStackName(stack);
        CheckDNSAvailabilityResult r = checkDNS(domainName);
        if (r.isAvailable()) {
            cr.setCNAMEPrefix(domainName);
            CreateEnvironmentResult res = beanstalkClient.createEnvironment(cr);
            journal.log(Level.INFO, ">> Status of the environment creation: " + res.toString());
        } else {
            journal.log(Level.INFO, ">> Status of the environment creation: Domain Name already existing");
        }
    } else {
        journal.log(Level.INFO, ">> Status of the environment creation: This type of stack does not exist!");
    }
}
 
Example #2
Source File: BeanstalkConnector.java    From cloudml with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String createEnvironmentWithWar(String applicationName, String domainName, String envName, String stackName, int minRam, String warFile, String versionLabel) {
    String endPoint="";
    prepareWar(new File(warFile), versionLabel, applicationName);
    CreateEnvironmentRequest cr = new CreateEnvironmentRequest();

    cr.setApplicationName(applicationName);
    cr.setEnvironmentName(envName);
    cr.setVersionLabel(versionLabel);
    String stack = findSolutionStack(stackName);
    if (!stack.equals("")) {
        cr.setSolutionStackName(stack);
        CheckDNSAvailabilityResult r = checkDNS(domainName);
        if (r.isAvailable()) {
            cr.setCNAMEPrefix(domainName);
            CreateEnvironmentResult res = beanstalkClient.createEnvironment(cr);
            endPoint=res.getEndpointURL();
            journal.log(Level.INFO, ">> Status of the environment creation: " + res.toString());
        } else {
            journal.log(Level.INFO, ">> Status of the environment creation: Domain Name already existing");
        }
    } else {
        journal.log(Level.INFO, ">> Status of the environment creation: This type of stack does not exist!");
    }
    return endPoint;
}
 
Example #3
Source File: CreateBeanstalkEnvironmentTask.java    From aws-ant-tasks with Apache License 2.0 4 votes vote down vote up
public void execute() {
    checkParams();
    AWSElasticBeanstalkClient client = getOrCreateClient(AWSElasticBeanstalkClient.class);
    CreateEnvironmentRequest eRequest = new CreateEnvironmentRequest(
            applicationName, environmentName)
            .withDescription(environmentDescription)
            .withVersionLabel(versionLabel)
            .withSolutionStackName(solutionStackName);
    if (!(tierName == null || tierType == null || tierVersion == null)) {
        eRequest.setTier(new EnvironmentTier().withName(tierName)
                .withType(tierType).withVersion(tierVersion));
    }

    if (cnamePrefix != null) {
        CheckDNSAvailabilityResult dnsResult = client
                .checkDNSAvailability(new CheckDNSAvailabilityRequest(
                        cnamePrefix));
        if (!dnsResult.isAvailable()) {
            throw new BuildException("The specified CNAME " + cnamePrefix
                    + " was not available");
        }
        eRequest.setCNAMEPrefix(cnamePrefix);
    }
    List<ConfigurationOptionSetting> optionSettings = new LinkedList<ConfigurationOptionSetting>();
    for (Setting setting : settings) {
        optionSettings.add(new ConfigurationOptionSetting(setting
                .getNamespace(), setting.getOptionName(), setting
                .getValue()));
    }
    if (optionSettings.size() > 0) {
        eRequest.setOptionSettings(optionSettings);
    }
    System.out.println("Creating environment " + environmentName + "...");
    String cNAME = "";
    try {
        CreateEnvironmentResult result = client.createEnvironment(eRequest);
        if ((cNAME = result.getCNAME()) == null) {
            System.out
                    .println("Create environment request submitted. The environment configuration does not support a CNAME.");
        } else {
            System.out
                    .println("Create environment request submitted. When the environment is finished launching, your deployment will be available at "
                            + cNAME);
        }
    } catch (Exception e) {
        throw new BuildException(
                "Exception while attempting to create environment: "
                        + e.getMessage(), e);
    }

}