
com.atlassian.maven.plugins.aws.it.ProvisionerMojo Maven / Gradle / Ivy
The newest version!
package com.atlassian.maven.plugins.aws.it;
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;
/**
*
* - Provisions AWS infrastructure via AWS CloudFormation template.
* - Has IAM capabilities.
* - Generates access keys.
* - Logs potentially useful commands.
*
*
* For an example on how to See the template used in the integration tests of this plugin.
* If you're not from Atlassian and you don't have the access to test sources, you need to rely on official AWS guides.
* We might open the repository for public read access in the future to avoid this friction.
*/
@Mojo(name = "provision-aws", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST)
public class ProvisionerMojo extends AbstractMojo {
/**
*
Pre-conditions
* A valid AWS region with the capabilities to provision infrastructure as defined by the CloudFormation template.
* Post-conditions
* All provisioned resources are contained in the region.
*/
@Parameter(
defaultValue = "eu-central-1",
property = "aws.region"
)
private String awsRegion;
/**
* The template is responsible for:
*
* - Creation of your integration test infrastructure.
* - Blocking to ensure that your EC2 instances are configured when provision completes.
* - Ensuring SSM Agent is installed if the execute-aws is used.
*
*
* @see CloudFormation
* @see CreationPolicy
* @see SSM prerequisites
*/
@Parameter(
defaultValue = "${basedir}/src/resources/cloudformation.template",
property = "aws.cloudformation.template"
)
private File cloudformationTemplate;
/**
* Pre-conditions
* It is a readable and writable directory.
* Post-conditions
* It contains data describing the provisioned infrastructure, which is consumable by other goals.
*/
@Parameter(
defaultValue = "${project.build.directory}",
readonly = true
)
private File workingDirectory;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Provisioner provisioner = new Provisioner(
awsRegion,
workingDirectory,
new StackInfoProvider(workingDirectory),
getLog()
);
provisioner.provision(cloudformationTemplate);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy