Quick Start

Deploy to Beanstalk

To use the plugin, first declare the plugin in your pom.xml:

<plugin>
    <groupId>com.github.davidmoten</groupId>
    <artifactId>aws-maven-plugin</artifactId>
    <version>[plugin version]</version>
    <configuration>
        <awsAccessKey>${env.AWS_ACCESS_KEY}</awsAccessKey>
        <awsSecretAccessKey>${env.AWS_SECRET_ACCESS_KEY}</awsSecretAccessKey>
        <artifact>${project.build.directory}/my-artifact.war</artifact>
        <applicationName>my-application-name</applicationName>
        <environmentName>my-environment-name</environmentName>
        <region>ap-southeast-2</region>
        <!-- optional versionLabel -->
        <versionLabel>my-artifact-${maven.build.timestamp}.war</versionLabel>
        <!-- optional proxy config -->
        <httpsProxyHost>proxy.amsa.gov.au</httpsProxyHost>
        <httpsProxyPort>8080</httpsProxyPort>
        <httpsProxyUsername>user</httpsProxyUsername>
        <httpsProxyPassword>pass</httpsProxyPassword>
    </configuration>
</plugin>

Notes

  • If you don't access AWS via an https proxy then leave those configuration settings out.
  • You can also specify a <versionLabel> in configuration if you want. If you don't it is automatically generated for you using the application name and a timestamp.

Deploy

To deploy a war and get it running on Beanstalk:

export AWS_ACCESS_KEY=<your_key>
export AWS_SECRET_ACCESS_KEY=<your_secret>
mvn package aws:deploy

The user represented by the AWS access key must have put permission on S3 and full access permission on ElasticBeanstalk.

Deploy to Lambda

To use the plugin, first declare the plugin in your pom.xml:

<plugin>
    <groupId>com.github.davidmoten</groupId>
    <artifactId>aws-maven-plugin</artifactId>
    <version>[LATEST_VERSION]</version>
    <configuration>
        <awsAccessKey>${env.AWS_ACCESS_KEY}</awsAccessKey>
        <awsSecretAccessKey>${env.AWS_SECRET_ACCESS_KEY}</awsSecretAccessKey>
        <artifact>${project.build.directory}/my-artifact.war</artifact>
        <functionName>myFunction</functionName>
        <region>ap-southeast-2</region>
        <!-- optional proxy config -->
        <httpsProxyHost>proxy.amsa.gov.au</httpsProxyHost>
        <httpsProxyPort>8080</httpsProxyPort>
        <httpsProxyUsername>user</httpsProxyUsername>
        <httpsProxyPassword>pass</httpsProxyPassword>
    </configuration>
</plugin>

Notes:

  • If you don't access AWS via an https proxy then leave those configuration settings out.
  • Adding AWSLambdaFullAccess managed policy to your user in IAM doesn't give you the ability to call UpdateFunctionCode. To fix this add an inline policy as below:
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "Stmt1464440182000",
                "Effect": "Allow",
                "Action": [
                    "lambda:InvokeAsync",
                    "lambda:InvokeFunction",
                    "lambda:UpdateFunctionCode"
                ],
                "Resource": [
                    "*"
                ]
            }
        ]
    }

Deploy

To deploy a jar and get it running on Lambda:

export AWS_ACCESS_KEY=<your_key>
export AWS_SECRET_ACCESS_KEY=<your_secret>
mvn package aws:deployLambda