Skip to content

This example demonstrates how to setup a simple HTTP GET endpoint using Clojure. Once you ping it, it will reply with the current time.

License

Notifications You must be signed in to change notification settings

Pyons/aws-clojure-simple-http-endpoint

Repository files navigation

Simple HTTP Endpoint Example

This example demonstrates how to setup a simple HTTP GET endpoint using Clojure. Once you ping it, it will reply with the current time.

Based on: aws-java-simple-http-endpoint

Use Cases

  • Wrapping an existing internal or external endpoint/service

Build

It is required to build prior to deploying. You can build the deployment artifact using Leiningen.

lein uberjar

Resulting uberjar is located at: target/uberjar/aws-clojure-simple-http-endpoint.jar

package:
  artifact: target/uberjar/aws-clojure-simple-http-endpoint.jar

Deploy

Change the region inside the serverless.yml to match your AWS region.

provider:
  ...
  region: eu-central-1

After having built the deployment artifact using Leiningen you can deploy by simply running

serverless deploy

Usage

You can now invoke the Lambda function directly and see the resulting log via

serverless invoke -f current-time --log

The expected result should be similar to:

{
    "statusCode": 200,
    "body": "{\"message\":\"Hello, the current time is Wed Jan 04 23:44:37 UTC 2017\"}",
    "headers": {
        "Access-Control-Allow-Origin": "*"
        "Content-Type": "application/json"
    }
}
--------------------------------------------------------------------
START RequestId: XXXXXXX Version: $LATEST
2019 23:44:37 <XXXXXXX> INFO  com.serverless.Handler:18 - received: {}
END RequestId: XXXXXXX
REPORT RequestId: XXXXXXX	Duration: 0.51 ms	Billed Duration: 100 ms 	Memory Size: 256 MB	Max Memory Used: 53 MB

Finally you can send an HTTP request directly to the endpoint using a tool like curl

curl https://XXXXXXX.execute-api.{REGION}.amazonaws.com/dev/ping

The expected result should be similar to:

{"message": "Hello, the current time is Wed Jan 04 23:44:37 +0000"}%  

Scaling

By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 100. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in To request a limit increase for concurrent executions.

About

This example demonstrates how to setup a simple HTTP GET endpoint using Clojure. Once you ping it, it will reply with the current time.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published