GithubHelp home page GithubHelp logo

lambdafunctions's Introduction

Lambda Functions

An introduction to lambda functions and a guide to implementing lambda functions in multiple languages.

1. Introduction

What is AWS Lambda?

Lambda is a compute service offered by AWS (and competitors, but we'll cover other platforms in another article) that you can run without creating or managing servers. The code is only executed when you need it - and there is not charge for it when it is not running.

The code is run in response to events - i.e. changes to data in an S3 bucket or an Amazon DynamoDB table, HTTP requests using API Gateway, or a number of other events. You can use lambda functions to build entire serverless applications deployed using codepipeline or codebuild (AWS services)

Java

Unlike Nodejs and Python - AWS Lambda functions authored in Java cannot solely be created using the console. The Java functions must be created locally and compiled to either a .jar or .zip file. We will go through both methods in this document. After compiling the file must be uploaded to AWS via the CLI or the console.

There are 3 ways by which you can import the Amazon SDK into your Java project

1. Through Apache Maven
2. Through Gradle
3. Through the Eclipse Toolkit for AWS

This tutorial was built using Eclipse - so we are assuming that you will be using #3, but you are free to follow the AWS Guide (https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-install.html) for installing the dependencies using the other methods.

Lesson learned - While creating this doc, I attempted to retroactively package the java project - meaning I created it as a normal java project and then tried to import the aws dependencies. This proved to be a disaster - I then blew it away and restarted using the AWS toolkit for eclipse to create the package. This is the method that I recommend using. It makes life a lot easier

Start by installing the AWS toolkit for ecplise through the eclipse market place. While it is installing, make an IAM role for the lambda function to invoke and make sure the role has the correct permissions for lambda access. Once the Eclipse toolkit is installed then configure the access keys through the system preferences.

Start a new "Java Lambda Project" using the AWS Toolkit in the toolbar.

**INFo about the code

The code is going to be hosted in an S3 bucket, so we must have an S3 bucket created for it. The AWS toolkit will build the code for you into a zip file when you use the toolkit to push it to your S3 bucket.
Once the code is build and pushed to S3 you can test it by right clicking in the Eclipse window for the class and selecting "Run function on AWS Lambda". You can also test on the AWS Lambda console by creating a test configuration.

lambdafunctions's People

Contributors

buonappetort avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.