demo_aws_lambda_function_java

Demo of AWS lambda function as Java source code

https://github.com/joelparkerhenderson/demo_aws_lambda_function_java

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.0%) to scientific vocabulary
Last synced: 8 months ago · JSON representation ·

Repository

Demo of AWS lambda function as Java source code

Basic Info
  • Host: GitHub
  • Owner: joelparkerhenderson
  • Language: Java
  • Default Branch: master
  • Size: 7.81 KB
Statistics
  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Created over 6 years ago · Last pushed about 1 year ago
Metadata Files
Readme Code of conduct Citation

README.md

Demo AWS lambda function as Java

This demonstration shows:

  • AWS Lambda
  • Java programming langauage
  • Maven package tool

Contents:

Create a project

Create a Maven project:

sh mvn -B archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DgroupId=com.joelparkerhenderson \ -DartifactId=demo-aws-lamba-function-hello-world-java cd demo-aws-lamba-function-hello-world-java mvn compile

If you get this error:

sh [ERROR] Source option 6 is no longer supported. Use 7 or later. [ERROR] Target option 6 is no longer supported. Use 7 or later.

Then edit pom.xml to upgrade the Java version to the highest available on AWS Lamba, which is currently Java 11, by adding these lines:

xml <project …> … <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> …

Then retry:

sh mvn compile

Output:

sh … [INFO] Building demo-aws-lamba-function-hello-world-java 1.0-SNAPSHOT … [INFO] BUILD SUCCESS

Add AWS lamba

Add AWS dependency to pom.xml:

xml <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-lambda-java-core</artifactId> <version>1.2.0</version> </dependency>

Add build with maven-shade-plugin. The plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.

xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.1</version> <configuration> <createDependencyReducedPom>false</createDependencyReducedPom> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> </plugins> </build>

Source

Create a main class such as Hello.java to handle each request:

```java package com.joelparkerhenderson;

import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.LambdaLogger; import com.amazonaws.services.lambda.runtime.RequestHandler;

public class Hello implements RequestHandler {

public ResponseClass handleRequest(RequestClass request, Context context){
    String greeting = String.format("Hello %s", request.name);
    return new ResponseClass(greeting);
}

} ```

Create a AWS Lamba RequestClass to serialize input from JSON:

```java package com.joelparkerhenderson;

public class RequestClass { String name;

public String gettName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}


public RequestClass(String name) {
    this.name = name;
}

public RequestClass() {
}

} ```

Create a AWS Lamba ResponseClass to serialize output to JSON:

```java package com.joelparkerhenderson;

public class ResponseClass { String greeting;

public String getGreeting() {
    return greeting;
}

public void setGreeting(String greeting) {
    this.greeting = greeting;
}

public ResponseClass(String greeting) {
    this.greeting = greeting;
}

public ResponseClass() {
}

} ```

Owner

  • Name: Joel Parker Henderson
  • Login: joelparkerhenderson
  • Kind: user
  • Location: California

Software developer. Technology consultant. Creator of GitAlias.com, NumCommand.com, SixArm.com, and many open source projects.

Citation (CITATION.cff)

cff-version: 1.2.0
title: Demo AWS lambda function as Java
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/joelparkerhenderson/demo_aws_lambda_function_java/'
    description: Demo AWS lambda function as Java
repository-code: 'https://github.com/joelparkerhenderson/demo_aws_lambda_function_java/'
abstract: >-
  Demo AWS lambda function as Java
license: See license file

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 3
  • Total Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 3
Committer Domains (Top 20 + Academic)