Example usage for com.amazonaws.services.elasticbeanstalk AWSElasticBeanstalk deleteApplication

List of usage examples for com.amazonaws.services.elasticbeanstalk AWSElasticBeanstalk deleteApplication

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticbeanstalk AWSElasticBeanstalk deleteApplication.

Prototype

DeleteApplicationResult deleteApplication(DeleteApplicationRequest deleteApplicationRequest);

Source Link

Document

Deletes the specified application along with all associated versions and configurations.

Usage

From source file:fr.xebia.cloud.amazon.aws.tools.AmazonAwsUtils.java

License:Apache License

/**
 * Delete given application and wait for its removal.
 *
 * @param applicationName/*from w w  w .ja v a 2s .  com*/
 * @param beanstalk
 */
public static void deleteBeanstalkApplicationIfExists(@Nonnull String applicationName,
        @Nonnull AWSElasticBeanstalk beanstalk) {
    ApplicationDescription application = Iterables.getFirst(beanstalk
            .describeApplications(new DescribeApplicationsRequest().withApplicationNames(applicationName))
            .getApplications(), null);
    if (application == null) {
        logger.debug("No application named '{}' found", applicationName);
        return;
    }

    synchronousTerminateEnvironments(applicationName, beanstalk);

    beanstalk.deleteApplication(new DeleteApplicationRequest().withApplicationName(applicationName));
    logger.info("Existing application {} deleted", applicationName);

    int counter = 0;
    while (application != null && counter < 1 * 60) {
        logger.debug("Wait for deletion of application {}", application);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw Throwables.propagate(e);
        }
        application = Iterables.getFirst(beanstalk
                .describeApplications(new DescribeApplicationsRequest().withApplicationNames(applicationName))
                .getApplications(), null);
    }
    if (application == null) {
        logger.info("Application {} successfully deleted", applicationName);
    } else {
        logger.warn("Failure to delete application {}", applicationName);
    }
}

From source file:jp.classmethod.aws.gradle.elasticbeanstalk.AWSElasticBeanstalkDeleteApplicationTask.java

License:Apache License

@TaskAction
public void deleteApplication() {
    // to enable conventionMappings feature
    String appName = getAppName();

    AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class);
    AWSElasticBeanstalk eb = ext.getClient();

    eb.deleteApplication(new DeleteApplicationRequest(appName));
    getLogger().info("application " + appName + " deleted");
}