All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.atlassian.maven.plugins.aws.it.ExecutorMojo Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package com.atlassian.maven.plugins.aws.it;

import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagement;
import com.amazonaws.services.simplesystemsmanagement.AWSSimpleSystemsManagementClientBuilder;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.io.File;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 
    *
  • Runs a given shell command targeted at tagged EC2 instances.
  • *
  • Uses Amazon EC2 Systems Manager.
  • *
  • Polls for successful execution status.
  • *
  • Dumps command output to a predefined S3 bucket.
  • *
  • Downloads all objects from given provisioned S3 buckets.
  • *
* * @see AWS prerequisites */ @Mojo(name = "execute-aws", defaultPhase = LifecyclePhase.INTEGRATION_TEST) public class ExecutorMojo extends AbstractMojo { /** *

Pre-conditions

* It is the working directory of provision-aws goal. *

Post-conditions

* Contains all objects from all provisioned S3 buckets. * The structure is: s3/$bucketLogicalId/$objectKey */ @Parameter( defaultValue = "${project.build.directory}", readonly = true ) private File workingDirectory; /** *

Pre-conditions

* They describe a sequence of shell scripts, which are supposed to work on the provisioned instances. *

Post-conditions

* Provisioned instances, filtered by tags, attempted to run all given commands. * All given commands are terminated. */ @Parameter private List steps; /** *

Pre-conditions

* It points to provisioned, writable S3 buckets. *

Post-conditions

* All S3 objects are downloaded from all given S3 buckets. * Downloads happen after all execution steps succeed. * No other S3 buckets are be downloaded. * Goal fails if any of the given buckets are not found. * Goal fails if any download fails. */ @Parameter private List s3Downloads; @Override public void execute() throws MojoExecutionException, MojoFailureException { StackInfo stackInfo = new StackInfoProvider(workingDirectory).read(); AWSSimpleSystemsManagement systemsManagement = AWSSimpleSystemsManagementClientBuilder.standard() .withRegion(stackInfo.getAwsRegion()) .build(); Executor executor = new Executor(systemsManagement, getLog()); Downloader downloader = new Downloader(workingDirectory, getLog()); List properSteps = steps.stream() .map(ExecutionStep::becomeProper) .collect(Collectors.toList()); executor.execute(properSteps, stackInfo.listInstances()); downloader.download(s3Downloads, stackInfo); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy