Prerequisites
To get the most out of this guide, you’ll need to:- Create a SendPost Account
- AWS Account with Lambda access
- A Sub-Account API Key from your SendPost dashboard
You can find your API keys in your SendPost Dashboard. Make sure to use your Sub-Account API Key for sending emails.
1. Node.js Lambda Function
Install Dependencies
Create apackage.json file:
JSON
npm
Basic Lambda Function
Createindex.js:
JavaScript
Environment Variables
In AWS Lambda Console, add environment variables:SENDPOST_API_KEY: your_sub_account_api_key
Deploy with AWS CLI
2. Python Lambda Function
Install Dependencies
Createrequirements.txt:
Basic Lambda Function
Createlambda_function.py:
Python
Deploy with AWS CLI
3. Common Use Cases
Welcome Email Lambda
Node.js version:JavaScript
Password Reset Email Lambda
Python version:Python
4. API Gateway Integration
Create API Gateway Endpoint
- Create a new API Gateway REST API
- Create a POST method
- Set integration type to Lambda Function
- Select your Lambda function
- Deploy to a stage
Example Request
5. Using Lambda Layers (Node.js)
Create Layer
Use Layer in Lambda
Attach the layer to your Lambda function in the AWS Console or via CLI:6. Error Handling & Logging
Enhanced Error Handling
JavaScript
7. Testing Locally
Using SAM CLI
Createtemplate.yaml:
Using Lambda Runtime Interface Emulator
8. Next Steps
Explore more examples and use cases:AWS Lambda Documentation
Learn more about AWS Lambda
SendPost JavaScript SDK
View the official SDK package on npm
SendPost Python SDK
View the official SDK package on PyPI
Quickstart Example
Complete working example from this quickstart guide