AWS Lambda is a popular serverless computing platform, but many users tend to rely on API Gateway to invoke their Lambda functions via HTTP requests. While API Gateway is highly integrated with Lambda, it can sometimes be overkill or incur additional costs depending on your specific use case. In this post, we'll explore an alternative way to invoke Lambda functions using RapidForge.
With RapidForge, you can avoid the overhead of API Gateway by using its webhook and periodic task features to invoke AWS Lambda functions directly from bash scripts. This approach provides a lightweight solution for running Lambda functions in response to HTTP requests or on a periodic schedule, without needing to build a full API Gateway integration.
AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
and AWS_DEFAULT_REGION
environment varibles for specific webhook or blockTo invoke a Lambda function via HTTP requests, start by creating a webhook in RapidForge.
InvokeLambdaWebhook
).Once the webhook is created, you need to attach a bash script that will execute when the webhook is triggered. This script will use the AWS CLI to call the Lambda function. You can inject environment variables from the request context into this script to pass data dynamically.
Here’s an example bash script that invokes a Lambda function:
# You can set this as env variable a well
LAMBDA_FUNCTION_NAME="MyLambdaFunction"
# Call the Lambda function using AWS CLI, super simple!
aws lambda invoke \
--function-name "$LAMBDA_FUNCTION_NAME" \
--payload "$PAYLOAD_DATA" \
/dev/stdout | jq -r '.body'
If you need to invoke Lambda functions on a schedule instead of via webhooks, RapidForge’s Periodic Tasks feature can help.
This way, RapidForge will automatically trigger the Lambda function at regular intervals, without the need for an HTTP request or API Gateway. This approach is especially useful for those who prefer to avoid the complexity of setting up API Gateway or need more control over how Lambda functions are invoked.