AWS Lambda function that receives Pulsetic alerts and sends SMS notifications via Twilio.
This project creates an AWS Lambda function with a public function URL that can receive webhook notifications from Pulsetic monitoring service. When an alert is received, it automatically sends an SMS notification using Twilio.
- 🚨 Receives Pulsetic webhook alerts
- 📱 Sends SMS notifications via Twilio
- ☁️ Serverless AWS Lambda deployment
- 🔧 Infrastructure as Code with Terraform
- 🌐 Public function URL (no API Gateway needed)
- AWS CLI configured with appropriate permissions
- Terraform installed (>= 1.0)
- Node.js and npm installed
- Twilio account with phone number
-
Clone and navigate to the project:
cd pulsetic-to-sms -
Install dependencies:
npm install
-
Configure Twilio and AWS settings:
cp terraform.tfvars.example terraform.tfvars
Edit
terraform.tfvarswith your actual values:twilio_account_sid: Your Twilio Account SIDtwilio_auth_token: Your Twilio Auth Tokentwilio_from_number: Your Twilio phone numberto_number: Phone number to receive alerts
-
Deploy the infrastructure:
chmod +x deploy.sh ./deploy.sh
-
Configure Pulsetic webhook:
- Copy the Lambda Function URL from the deployment output
- Add it as a webhook URL in your Pulsetic dashboard
Once deployed, the Lambda function will automatically:
- Receive POST requests from Pulsetic with alert data
- Parse the alert type and monitor information
- Format SMS messages with relevant details (monitor name, URL, status, response codes)
- Send SMS notifications to the configured phone number
- Return a success/error response to Pulsetic
The function handles different Pulsetic alert types:
- monitor_offline: 🚨 Alert when a monitor goes offline with response code and failure reason
- monitor_online: ✅ Alert when a monitor comes back online
- Other alerts: 📊 Generic alert format with monitor details
The function expects Pulsetic alerts in this format:
{
"alert_type": "monitor_offline",
"monitor": {
"id": 74710,
"url": "https://example.com",
"name": "Example Monitor",
"response_code": 500,
"fail_reason": "Connection timeout"
}
}alert_type: Type of alert (e.g., "monitor_offline", "monitor_online")monitor.id: Unique monitor identifiermonitor.url: The URL being monitoredmonitor.name: Human-readable monitor namemonitor.response_code: HTTP response code (for offline alerts)monitor.fail_reason: Reason for failure (for offline alerts)
SMS messages are formatted based on the alert type:
Monitor Offline:
🚨 Monitor Offline: [Monitor Name]
URL: [URL]
Response Code: [Code]
Reason: [Fail Reason]
Monitor Online:
✅ Monitor Online: [Monitor Name]
URL: [URL]
Monitor is back online
- AWS Lambda: Serverless function to process webhooks
- Lambda Function URL: Direct HTTP endpoint (no API Gateway needed)
- Twilio: SMS service provider
- Terraform: Infrastructure as Code for deployment
The Lambda function uses these environment variables (set via Terraform):
TWILIO_ACCOUNT_SID: Twilio Account SIDTWILIO_AUTH_TOKEN: Twilio Auth TokenTWILIO_FROM_NUMBER: Twilio phone number to send fromTO_NUMBER: Phone number to receive notifications
CloudWatch logs are automatically created for the Lambda function at:
/aws/lambda/pulsetic-to-sms
To destroy all resources:
terraform destroy- The function URL is public but only accepts POST requests
- Twilio credentials are stored as environment variables
- CloudWatch logs retention is set to 14 days
- All sensitive variables are marked as sensitive in Terraform
This solution uses AWS Lambda's free tier (1M requests/month) and minimal CloudWatch logging. Costs are primarily from:
- Lambda execution time (very minimal)
- Twilio SMS charges
- Minimal CloudWatch storage