Skip to content

Instantly share code, notes, and snippets.

@aldrinleal
Last active December 29, 2015 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aldrinleal/dba89d1b12b065171ff4 to your computer and use it in GitHub Desktop.
Save aldrinleal/dba89d1b12b065171ff4 to your computer and use it in GitHub Desktop.
Lambada Sample
```
$ mvn -Pdeploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building lambada-functions 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalk-maven-plugin/1.4.2/beanstalk-maven-plugin-1.4.2.pom
Downloaded: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalk-maven-plugin/1.4.2/beanstalk-maven-plugin-1.4.2.pom (3 KB at 1.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalker/1.4.2/beanstalker-1.4.2.pom
Downloaded: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalker/1.4.2/beanstalker-1.4.2.pom (13 KB at 33.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalk-maven-plugin/1.4.2/beanstalk-maven-plugin-1.4.2.jar
Downloaded: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalk-maven-plugin/1.4.2/beanstalk-maven-plugin-1.4.2.jar (194 KB at 208.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/br/com/ingenieux/lambda-maven-plugin/1.4.2/lambda-maven-plugin-1.4.2.pom
Downloaded: https://repo.maven.apache.org/maven2/br/com/ingenieux/lambda-maven-plugin/1.4.2/lambda-maven-plugin-1.4.2.pom (2 KB at 3.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/br/com/ingenieux/lambda-maven-plugin/1.4.2/lambda-maven-plugin-1.4.2.jar
Downloaded: https://repo.maven.apache.org/maven2/br/com/ingenieux/lambda-maven-plugin/1.4.2/lambda-maven-plugin-1.4.2.jar (21 KB at 17.2 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lambada-functions ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/aldrin/projetos/sources/lambada-functions/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ lambada-functions ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- lambada-maven-plugin:0.0.1-SNAPSHOT:generate (default) @ lambada-functions ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ lambada-functions ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ lambada-functions ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ lambada-functions ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ lambada-functions ---
[INFO] Building jar: /home/aldrin/projetos/sources/lambada-functions/target/lambada-functions.jar
[INFO]
[INFO] --- maven-shade-plugin:2.3:shade (default) @ lambada-functions ---
[INFO] Including com.amazonaws:aws-lambda-java-core:jar:1.1.0 in the shaded jar.
[INFO] Including io.ingenieux.lambada:lambada-runtime:jar:0.0.1-SNAPSHOT in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /home/aldrin/projetos/sources/lambada-functions/target/lambada-functions.jar with /home/aldrin/projetos/sources/lambada-functions/target/lambada-functions-0.0.1-SNAPSHOT-shaded.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ lambada-functions ---
[INFO] Skipping artifact installation
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ lambada-functions ---
[INFO] Skipping artifact deployment
[INFO]
[INFO] --- beanstalk-maven-plugin:1.4.2:upload-source-bundle (deploy) @ lambada-functions ---
Downloading: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalker-common/1.4.2/beanstalker-common-1.4.2.pom
Downloaded: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalker-common/1.4.2/beanstalker-common-1.4.2.pom (3 KB at 6.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalker-common/1.4.2/beanstalker-common-1.4.2.jar
Downloaded: https://repo.maven.apache.org/maven2/br/com/ingenieux/beanstalker-common/1.4.2/beanstalker-common-1.4.2.jar (20 KB at 60.7 KB/sec)
[INFO] Target Path: s3://ingenieux-images/apps/lambada-functions/lambada-functions-20151229193725.zip
[INFO] Uploading artifact file: /home/aldrin/projetos/sources/lambada-functions/target/lambada-functions.jar
[INFO] Artifact Uploaded
[INFO] SUCCESS
[INFO] {
[INFO] "contentMd5" : "0PHJfxpLmAVbZpGPDw6g+A==",
[INFO] "metadata" : {
[INFO] "userMetadata" : { },
[INFO] "contentLength" : 0,
[INFO] "etag" : "d0f1c97f1a4b98055b66918f0f0ea0f8",
[INFO] "rawMetadata" : {
[INFO] "Content-Length" : 0,
[INFO] "ETag" : "d0f1c97f1a4b98055b66918f0f0ea0f8"
[INFO] },
[INFO] "instanceLength" : 0
[INFO] },
[INFO] "etag" : "d0f1c97f1a4b98055b66918f0f0ea0f8"
[INFO] }
[INFO]
[INFO] --- lambda-maven-plugin:1.4.2:deploy-functions (deploy) @ lambada-functions ---
[INFO] Looking up IAM Role 'arn:aws:iam::*:role/lambda_basic_execution'
[INFO] Found Role: 'arn:aws:iam::235368163414:role/lambda_basic_execution'
[INFO] Loaded and replaced definitions from file '/home/aldrin/projetos/sources/lambada-functions/target/classes/META-INF/lambada/lambada-functions.json'
[INFO] Found 1 definitions:
[INFO] Merged into 1 definitions:
[INFO] Deploying Function: fn_say_hello (handler: br.com.ingenieux.lambada.example.LambadaFunctions::sayHello)
[INFO] SUCCESS
[INFO] {
[INFO] "fn_say_hello" : {
[INFO] "name" : "fn_say_hello",
[INFO] "description" : "",
[INFO] "memorySize" : 128,
[INFO] "role" : "arn:aws:iam::235368163414:role/lambda_basic_execution",
[INFO] "timeout" : 5,
[INFO] "handler" : "br.com.ingenieux.lambada.example.LambadaFunctions::sayHello"
[INFO] }
[INFO] }
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.715 s
[INFO] Finished at: 2015-12-29T14:37:38-05:00
[INFO] Final Memory: 21M/216M
[INFO] ------------------------------------------------------------------------
aldrin@aldrin-X555LD lambada-functions $
```
package br.com.ingenieux.lambada.example;
import io.ingenieux.lambada.maven.ann.LambadaFunction;
import static java.lang.String.format;
public class LambadaFunctions {
@LambadaFunction(name="fn_say_hello")
public String sayHello(String whom) {
return format("Hola, %s", whom);
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.ingenieux.lambada</groupId>
<artifactId>lambada-functions</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<lambada.version>0.0.1-SNAPSHOT</lambada.version>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>io.ingenieux.lambada</groupId>
<artifactId>lambada-maven-plugin</artifactId>
<version>${lambada.version}</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>io.ingenieux.lambada</groupId>
<artifactId>lambada-runtime</artifactId>
<version>${lambada.version}</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>deploy</id>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.install.skip>true</maven.install.skip>
<maven.test.skip>true</maven.test.skip>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<beanstalk.versionLabel>${maven.build.timestamp}</beanstalk.versionLabel>
<beanstalk.s3Bucket>ingenieux-images</beanstalk.s3Bucket>
<beanstalk.s3Key>apps/${project.artifactId}/${project.build.finalName}-${beanstalk.versionLabel}.zip
</beanstalk.s3Key>
<beanstalk.artifactFile>${project.build.directory}/${project.build.finalName}.jar
</beanstalk.artifactFile>
</properties>
<build>
<defaultGoal>deploy</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*:*:*</artifact>
<excludes>
<exclude>*.RSA</exclude>
<exclude>*.DSA</exclude>
<exclude>*.SF</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>br.com.ingenieux</groupId>
<artifactId>beanstalk-maven-plugin</artifactId>
<version>1.4.2</version>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>upload-source-bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<multipartUpload>false</multipartUpload>
</configuration>
</plugin>
<plugin>
<groupId>br.com.ingenieux</groupId>
<artifactId>lambda-maven-plugin</artifactId>
<version>1.4.2</version>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy-functions</goal>
</goals>
</execution>
</executions>
<configuration>
<s3Url>s3://${beanstalk.s3Bucket}/${beanstalk.s3Key}</s3Url>
<definitionFile>${project.build.outputDirectory}/META-INF/lambada/lambada-functions.json
</definitionFile>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment