Giter VIP home page Giter VIP logo

aws-lambda-terraform-java-play's Introduction

aws-lambda-terraform-java

This is a very simple demonstration of the code required to deploy a Java AWS Lambda Function and expose the function with AWS API Gateway. The infrastructure configuration and deployment is executed using HashiCorp's Terraform programmable infrastructure tool.

Get started

To get started simply create a terraform.tfvars file in terraform directory with your AWS account/IAM User details. Your IAM User must have permissions for AWS Lambda and AWS API Gateway.

The contents should follow the template below (with you replacing the info between << >>):

aws_access_key = "<< your IAM user AWS access key >>"
aws_secret_key = "<< your IAM user AWS secret key >>"
region = "<< your chosen region >>"
account_id = "<<your AWS account id>>"

From the root of the project run the build_and_deploy.sh script. This compiles the Java application into the helloworld/target directory and runs Terraform to upload and configure the Lambda function and API Gateway.

$ ./build_and_deploy.sh

Manually test your function

After a successful run, something similar to the output below should be visible:

Outputs:

curl = curl -H 'Content-Type: application/json' -X POST -d '{"name": "Daniel"}' https://XXXXXXXXXX.execute-api.eu-west-1.amazonaws.com/beta/helloworld

To test your Lambda deployed behind the API Gateway all you need to do is copy/paste the curl command (minus the curl = part) e.g.

curl -H 'Content-Type: application/json' -X POST -d '{"name": "Daniel"}' https://XXXXXXXXXX.execute-api.eu-west-1.amazonaws.com/beta/helloworld

Rinse and repeat

You can make changes to the Java application and run the build_and_deploy.sh script repeatedly to update the Lambda Function deployed into AWS.

Tidy up when finished!

When you are finished, don't forget to shut your infrastructure down:

$ ./destroy.sh

Disclaimer

Please note: I'm not responsible for any costs incurred within your AWS account :-)

aws-lambda-terraform-java-play's People

Contributors

danielbryantuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.