List of usage examples for com.amazonaws.services.elasticbeanstalk AWSElasticBeanstalk updateConfigurationTemplate
UpdateConfigurationTemplateResult updateConfigurationTemplate( UpdateConfigurationTemplateRequest updateConfigurationTemplateRequest);
Updates the specified configuration template to have the specified properties or configuration option values.
From source file:jp.classmethod.aws.gradle.elasticbeanstalk.AWSElasticBeanstalkCreateConfigurationTemplateTask.java
License:Apache License
@TaskAction public void createTemplate() { // to enable conventionMappings feature String appName = getAppName(); AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class); AWSElasticBeanstalk eb = ext.getClient(); configurationTemplates.forEach(config -> { String templateName = config.getName(); String templateDesc = config.getDesc(); String solutionStackName = config.getSolutionStackName() != null ? config.getSolutionStackName() : getDefaultSolutionStackName(); boolean deleteTemplateIfExists = config.isRecreate(); try {//w w w . ja va 2 s .c o m List<ConfigurationOptionSetting> optionSettings = loadConfigurationOptions( config.getOptionSettings()); List<ApplicationDescription> existingApps = eb .describeApplications(new DescribeApplicationsRequest().withApplicationNames(appName)) .getApplications(); if (existingApps.isEmpty()) { throw new IllegalArgumentException("App with name '" + appName + "' does not exist"); } if (existingApps.get(0).getConfigurationTemplates().contains(templateName)) { if (deleteTemplateIfExists) { eb.deleteConfigurationTemplate(new DeleteConfigurationTemplateRequest() .withApplicationName(appName).withTemplateName(templateName)); getLogger().info("configuration template {} @ {} deleted", templateName, appName); } else { eb.updateConfigurationTemplate(new UpdateConfigurationTemplateRequest() .withApplicationName(appName).withTemplateName(templateName) .withDescription(templateDesc).withOptionSettings(optionSettings)); getLogger().info("configuration template {} @ {} updated", templateName, appName); return; } } eb.createConfigurationTemplate(new CreateConfigurationTemplateRequest().withApplicationName(appName) .withTemplateName(templateName).withDescription(templateDesc) .withSolutionStackName(solutionStackName).withOptionSettings(optionSettings)); getLogger().info("configuration template {} @ {} created", templateName, appName); } catch (IOException e) { getLogger().error("IOException", e); } }); }