Search in sources :

Example 1 with CreateConfigurationTemplateRequest

use of com.amazonaws.services.elasticbeanstalk.model.CreateConfigurationTemplateRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElasticBeanstalkSetupTest method testCreateConfigurationTemplate.

@Test
public void testCreateConfigurationTemplate() {
    List<ConfigurationOptionSetting> cfgOptSettings = new ArrayList<ConfigurationOptionSetting>();
    String templateName = "newTemplate";
    DescribeConfigurationOptionsRequest dcoReq = new DescribeConfigurationOptionsRequest().withApplicationName(config.getElasticBeanstalkApplicationName()).withTemplateName(templateName);
    AmazonServiceException expectedAmznException = new AmazonServiceException("Invalid template name");
    expectedAmznException.setErrorCode("InvalidParameterValue");
    when(mockClient.describeConfigurationOptions(dcoReq)).thenThrow(expectedAmznException);
    CreateConfigurationTemplateRequest expectedCctReq = new CreateConfigurationTemplateRequest();
    expectedCctReq.setApplicationName(config.getElasticBeanstalkApplicationName());
    expectedCctReq.setOptionSettings(cfgOptSettings);
    expectedCctReq.setSolutionStackName(Constants.SOLUTION_STACK_NAME_64BIT_TOMCAT8_JAVA8_2017_03_AMI);
    expectedCctReq.setTemplateName(templateName);
    setup.createOrUpdateConfigurationTemplate(templateName, cfgOptSettings);
    verify(mockClient).createConfigurationTemplate(expectedCctReq);
}
Also used : ArrayList(java.util.ArrayList) AmazonServiceException(com.amazonaws.AmazonServiceException) CreateConfigurationTemplateRequest(com.amazonaws.services.elasticbeanstalk.model.CreateConfigurationTemplateRequest) ConfigurationOptionSetting(com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting) DescribeConfigurationOptionsRequest(com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsRequest) Test(org.junit.Test)

Example 2 with CreateConfigurationTemplateRequest

use of com.amazonaws.services.elasticbeanstalk.model.CreateConfigurationTemplateRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class ElasticBeanstalkSetup method createOrUpdateConfigurationTemplate.

/**
 * Create or get the Configuration template
 * @return
 */
public DescribeConfigurationOptionsResult createOrUpdateConfigurationTemplate(final String templateName, final List<ConfigurationOptionSetting> cfgOptSettings) {
    // Add SSL arn based on templateSuffix
    DescribeConfigurationOptionsResult desc = describeConfigurationTemplate(templateName);
    if (desc == null) {
        logger.debug("Creating Elastic Beanstalk Template for the first time with name: " + templateName + "...");
        // We need to create it
        CreateConfigurationTemplateRequest request = new CreateConfigurationTemplateRequest();
        request.setApplicationName(config.getElasticBeanstalkApplicationName());
        request.setTemplateName(templateName);
        request.setSolutionStackName(Constants.SOLUTION_STACK_NAME_64BIT_TOMCAT8_JAVA8_2017_03_AMI);
        request.setOptionSettings(cfgOptSettings);
        beanstalkClient.createConfigurationTemplate(request);
    } else {
        logger.debug("Elastic Beanstalk Template already exists so updating it with name: " + templateName + "...");
        // If it exists then we want to update it
        UpdateConfigurationTemplateRequest request = new UpdateConfigurationTemplateRequest();
        request.setApplicationName(config.getElasticBeanstalkApplicationName());
        request.setTemplateName(templateName);
        request.setOptionSettings(cfgOptSettings);
        UpdateConfigurationTemplateResult updateResult = beanstalkClient.updateConfigurationTemplate(request);
        logger.debug(updateResult);
    }
    return describeConfigurationTemplate(templateName);
}
Also used : UpdateConfigurationTemplateResult(com.amazonaws.services.elasticbeanstalk.model.UpdateConfigurationTemplateResult) UpdateConfigurationTemplateRequest(com.amazonaws.services.elasticbeanstalk.model.UpdateConfigurationTemplateRequest) CreateConfigurationTemplateRequest(com.amazonaws.services.elasticbeanstalk.model.CreateConfigurationTemplateRequest) DescribeConfigurationOptionsResult(com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsResult)

Aggregations

CreateConfigurationTemplateRequest (com.amazonaws.services.elasticbeanstalk.model.CreateConfigurationTemplateRequest)2 AmazonServiceException (com.amazonaws.AmazonServiceException)1 ConfigurationOptionSetting (com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting)1 DescribeConfigurationOptionsRequest (com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsRequest)1 DescribeConfigurationOptionsResult (com.amazonaws.services.elasticbeanstalk.model.DescribeConfigurationOptionsResult)1 UpdateConfigurationTemplateRequest (com.amazonaws.services.elasticbeanstalk.model.UpdateConfigurationTemplateRequest)1 UpdateConfigurationTemplateResult (com.amazonaws.services.elasticbeanstalk.model.UpdateConfigurationTemplateResult)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1