List of usage examples for com.amazonaws.services.elasticbeanstalk.model CreateEnvironmentResult getEnvironmentName
public String getEnvironmentName()
The name of this environment.
From source file:fr.xebia.workshop.caching.CreateTomcat.java
License:Apache License
public void createServers() { String applicationName = "xfr-cocktail"; // CREATE APPLICATION AmazonAwsUtils.deleteBeanstalkApplicationIfExists(applicationName, beanstalk); CreateApplicationRequest createApplicationRequest = new CreateApplicationRequest() .withApplicationName(applicationName) .withDescription("xfr-cocktail app created at " + new DateTime()); ApplicationDescription applicationDescription = beanstalk.createApplication(createApplicationRequest) .getApplication();//from www .j a v a2 s. c om logger.debug("Application {} created", applicationDescription.getApplicationName()); // CREATE APPLICATION VERSION CreateApplicationVersionRequest createApplicationVersion1Request = new CreateApplicationVersionRequest() .withApplicationName(applicationDescription.getApplicationName()).withVersionLabel("1.0.0") .withSourceBundle(new S3Location("xfr-workshop-caching", "cocktail-app-1.0.0-SNAPSHOT.war")); ApplicationVersionDescription applicationVersion1Description = beanstalk .createApplicationVersion(createApplicationVersion1Request).getApplicationVersion(); logger.debug("Application version {}:{} created", applicationVersion1Description.getApplicationName(), applicationVersion1Description.getVersionLabel()); CreateApplicationVersionRequest createApplicationVersion11Request = new CreateApplicationVersionRequest() .withApplicationName(applicationDescription.getApplicationName()).withVersionLabel("1.1.0") .withSourceBundle(new S3Location("xfr-workshop-caching", "cocktail-app-1.1.0-SNAPSHOT.war")); ApplicationVersionDescription applicationVersion11Description = beanstalk .createApplicationVersion(createApplicationVersion11Request).getApplicationVersion(); logger.debug("Application version {}:{} created", applicationVersion11Description.getApplicationName(), applicationVersion11Description.getVersionLabel()); CreateApplicationVersionRequest createApplicationVersion12Request = new CreateApplicationVersionRequest() .withApplicationName(applicationDescription.getApplicationName()).withVersionLabel("1.2.0") .withSourceBundle(new S3Location("xfr-workshop-caching", "cocktail-app-1.2.0-SNAPSHOT.war")); ApplicationVersionDescription applicationVersion12Description = beanstalk .createApplicationVersion(createApplicationVersion12Request).getApplicationVersion(); logger.debug("Application version {}:{} created", applicationVersion12Description.getApplicationName(), applicationVersion12Description.getVersionLabel()); // CREATE CONFIGURATION TEMPLATE CreateConfigurationTemplateRequest createConfigurationTemplateRequest = new CreateConfigurationTemplateRequest() .withApplicationName(applicationDescription.getApplicationName()) .withTemplateName(applicationDescription.getApplicationName() + "-base-configuration") .withSolutionStackName("32bit Amazon Linux running Tomcat 7").withOptionSettings( new ConfigurationOptionSetting("aws:autoscaling:launchconfiguration", "InstanceType", "t1.micro"), new ConfigurationOptionSetting("aws:autoscaling:launchconfiguration", "EC2KeyName", workshopInfrastructure.getKeyPairName()), new ConfigurationOptionSetting("aws:elasticbeanstalk:sns:topics", "Notification Endpoint", workshopInfrastructure.getBeanstalkNotificationEmail()), new ConfigurationOptionSetting("aws:elasticbeanstalk:application:environment", "AWS_ACCESS_KEY_ID", workshopInfrastructure.getAwsAccessKeyId()), new ConfigurationOptionSetting("aws:elasticbeanstalk:application:environment", "AWS_SECRET_KEY", workshopInfrastructure.getAwsSecretKey())); CreateConfigurationTemplateResult configurationTemplateResult = beanstalk .createConfigurationTemplate(createConfigurationTemplateRequest); logger.debug("Configuration {}:{} created", configurationTemplateResult.getApplicationName(), configurationTemplateResult.getTemplateName(), configurationTemplateResult); for (String teamIdentifier : workshopInfrastructure.getTeamIdentifiers()) { // CREATE ENVIRONMENT CreateEnvironmentRequest createEnvironmentRequest = new CreateEnvironmentRequest() .withEnvironmentName(applicationDescription.getApplicationName() + "-" + teamIdentifier) .withApplicationName(applicationDescription.getApplicationName()) .withVersionLabel(applicationVersion1Description.getVersionLabel()) .withCNAMEPrefix(applicationDescription.getApplicationName() + "-" + teamIdentifier) .withTemplateName(configurationTemplateResult.getTemplateName()); CreateEnvironmentResult createEnvironmentResult = beanstalk.createEnvironment(createEnvironmentRequest); logger.info("Environment {}:{}:{} created at {}", createEnvironmentResult.getApplicationName(), createEnvironmentResult.getVersionLabel(), createEnvironmentResult.getEnvironmentName(), Strings.nullToEmpty(createEnvironmentResult.getEndpointURL())); } }
From source file:fr.xebia.workshop.nginx.CreateTomcat.java
License:Apache License
public void createServers() { String applicationName = "xfr-cocktail-nginx"; // CREATE APPLICATION AmazonAwsUtils.deleteBeanstalkApplicationIfExists(applicationName, beanstalk); CreateApplicationRequest createApplicationRequest = new CreateApplicationRequest() .withApplicationName(applicationName).withDescription("xfr-cocktail-nginx app"); ApplicationDescription applicationDescription = beanstalk.createApplication(createApplicationRequest) .getApplication();/* w w w .ja v a2 s.c o m*/ logger.debug("Application {} created", applicationDescription.getApplicationName()); // CREATE APPLICATION VERSION CreateApplicationVersionRequest createApplicationVersion1Request = new CreateApplicationVersionRequest() .withApplicationName(applicationDescription.getApplicationName()).withVersionLabel("1.0.0") .withSourceBundle(new S3Location("xfr-workshop-caching", "cocktail-app-1.0.0-SNAPSHOT.war")); ApplicationVersionDescription applicationVersion1Description = beanstalk .createApplicationVersion(createApplicationVersion1Request).getApplicationVersion(); logger.debug("Application version {}:{} created", applicationVersion1Description.getApplicationName(), applicationVersion1Description.getVersionLabel()); /*CreateApplicationVersionRequest createApplicationVersion11Request = new CreateApplicationVersionRequest() .withApplicationName(applicationDescription.getApplicationName()) .withVersionLabel("1.1.0") .withSourceBundle(new S3Location(XFR_WORKSHOP_NGINX, "cocktail-app-1.1.0-SNAPSHOT.war")); ApplicationVersionDescription applicationVersion11Description = beanstalk.createApplicationVersion(createApplicationVersion11Request).getApplicationVersion(); logger.debug("Application version {}:{} created", applicationVersion11Description.getApplicationName(), applicationVersion11Description.getVersionLabel()); */ // CREATE CONFIGURATION TEMPLATE CreateConfigurationTemplateRequest createConfigurationTemplateRequest = new CreateConfigurationTemplateRequest() .withApplicationName(applicationDescription.getApplicationName()) .withTemplateName(applicationDescription.getApplicationName() + "-base-configuration") .withSolutionStackName("32bit Amazon Linux running Tomcat 7").withOptionSettings( new ConfigurationOptionSetting("aws:autoscaling:launchconfiguration", "InstanceType", "t1.micro"), new ConfigurationOptionSetting("aws:autoscaling:launchconfiguration", "EC2KeyName", workshopInfrastructure.getKeyPairName()), new ConfigurationOptionSetting("aws:elasticbeanstalk:sns:topics", "Notification Endpoint", workshopInfrastructure.getBeanstalkNotificationEmail()), new ConfigurationOptionSetting("aws:elasticbeanstalk:application:environment", "AWS_ACCESS_KEY_ID", workshopInfrastructure.getAwsAccessKeyId()), new ConfigurationOptionSetting("aws:elasticbeanstalk:application:environment", "AWS_SECRET_KEY", workshopInfrastructure.getAwsSecretKey())); CreateConfigurationTemplateResult configurationTemplateResult = beanstalk .createConfigurationTemplate(createConfigurationTemplateRequest); logger.debug("Configuration {}:{} created", new Object[] { configurationTemplateResult.getApplicationName(), configurationTemplateResult.getTemplateName(), configurationTemplateResult }); for (String teamIdentifier : workshopInfrastructure.getTeamIdentifiers()) { for (int id = 0; id < 2; id++) { // CREATE ENVIRONMENT CreateEnvironmentRequest createEnvironmentRequest = new CreateEnvironmentRequest() .withEnvironmentName( applicationDescription.getApplicationName() + "-" + teamIdentifier + "-" + id) .withApplicationName(applicationDescription.getApplicationName()) .withVersionLabel(applicationVersion1Description.getVersionLabel()) .withCNAMEPrefix( applicationDescription.getApplicationName() + "-" + teamIdentifier + "-" + id) .withTemplateName(configurationTemplateResult.getTemplateName()); CreateEnvironmentResult createEnvironmentResult = beanstalk .createEnvironment(createEnvironmentRequest); logger.info("Environment {}:{}:{} created at {}", new Object[] { createEnvironmentResult.getApplicationName(), createEnvironmentResult.getVersionLabel(), createEnvironmentResult.getEnvironmentName(), createEnvironmentResult.getEndpointURL() }); } } }