Example usage for com.amazonaws.services.elasticbeanstalk.model CreateEnvironmentRequest setTemplateName

List of usage examples for com.amazonaws.services.elasticbeanstalk.model CreateEnvironmentRequest setTemplateName

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticbeanstalk.model CreateEnvironmentRequest setTemplateName.

Prototype


public void setTemplateName(String templateName) 

Source Link

Document

The name of the configuration template to use in deployment.

Usage

From source file:br.com.ingenieux.mojo.beanstalk.cmd.env.create.CreateEnvironmentCommand.java

License:Apache License

@Override
protected CreateEnvironmentResult executeInternal(CreateEnvironmentContext context) throws Exception {
    CreateEnvironmentRequest request = new CreateEnvironmentRequest();

    request.setApplicationName(context.getApplicationName());
    request.setCNAMEPrefix(parentMojo.ensureSuffixStripped(context.getCnamePrefix()));
    request.setDescription(context.getApplicationDescription());
    request.setEnvironmentName(context.getEnvironmentName());
    request.setTags(context.getTags());/*from w w w .ja v  a2s .c  o  m*/

    request.setOptionSettings(Arrays.asList(context.getOptionSettings()));
    request.setOptionsToRemove(Arrays.asList(context.getOptionsToRemove()));

    if ("Worker".equals(context.getEnvironmentTierName())) {
        if (contextDoesNotContainsEC2Role(context)) {
            parentMojo.getLog().warn(
                    "It is meaningless to launch a worker without an IAM Role. If you set in templateName, thats fine, but here's a warning for you");
        }
        ;
        context.setEnvironmentTierType(StringUtils.defaultString(context.getEnvironmentTierType(), "SQS/HTTP"));
        request.setCNAMEPrefix(null);
        request.setTier(new EnvironmentTier().withName(context.getEnvironmentTierName())
                .withType(context.getEnvironmentTierType()).withVersion(context.getEnvironmentTierVersion()));
    }

    if (StringUtils.isNotBlank(context.getTemplateName())) {
        request.setTemplateName(
                parentMojo.lookupTemplateName(context.getApplicationName(), context.getTemplateName()));
    } else if (StringUtils.isNotBlank(context.getSolutionStack())) {
        request.setSolutionStackName(context.getSolutionStack());
    }

    request.setVersionLabel(context.getVersionLabel());

    if (parentMojo.isVerbose()) {
        parentMojo.getLog()
                .info("Requesting createEnvironment w/ request: " + CredentialsUtil.redact("" + request));
    }

    return service.createEnvironment(request);
}