AWS Lambda environment variables and Raygun

AWS Lambda environment variables and Raygun

In our [previous ]( on AWS Lambda and Raygun Crash Reporting, we covered sending exception data from an AWS Lambda function written in Node.js. Recently AWS added support for [environment...

In our previous article on AWS Lambda and Raygun Crash Reporting, we covered sending exception data from an AWS Lambda function written in Node.js. Recently AWS added support for environment variables to be passed into Lambda functions. These environment variables allow you to set certain constants and then access them in your Lambda functions.

This new feature helps our customers by allowing you to specify your Raygun Crash Reporting API key in the AWS Lambda environment variables instead of hard coding it into your Lambda function. In this article I’ll be demonstrating how to setup our environment variables in AWS Lambda and then how to pass along custom data with other environment variables.

Getting Started

Step 1.

We will be using Node.js again for our example so the first thing we need to do is create an initial Node project. Create a new directory called awsnodeexample via command line.

mkdir awsnodeexample

Then switch to the new directory and create an index.js file to hold the sample code:

cd awsnodeexample/

touch index.js

Next, use Node Package Manager (npm) to create the Raygun Crash Reporting integration and install the necessary modules. This is the same process you would use to integrate Raygun with any Node.js application:

npm install raygun

If you are interested you can review our open source Node.js provider code in our Github repo.

Step 2.

The next step is to implement a simple function with error handling in our index.js:

// Include Raygun (note that the library and dependencies has been added to the packages directory)
var raygun = require('raygun');

exports.handler = (event, context, callback) => {


      var a = 0;
      var b = a.DoSomeMagicThing();
      console.log('Should never reach this');
    catch (e) {
      console.log('Sending to Raygun');
      // Send the error to Raygun
      var raygunClient = new raygun.Client().init({ apiKey: process.env.RAYGUN_API_KEY });

    callback(null, 'All done..');

raygun aws

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire AWS Developer

Looking to Hire Professional AWS Developers? The technology inventions have demanded all businesses to use and manage cloud-based computing services and Amazon is dominating the cloud computing services provider in the world. **[Hire AWS...

AWS Cost Allocation Tags and Cost Reduction

Learn more about AWS Cost Allocation Tags, tag examples via the web, CLI, and node.js, explore tag compliance services, and review tagging strategies.

Hire Dedicated AWS Developer

Want to Hire AWS Developer for cloud computing services? At **[]( "")**, we leverage maximum benefits from the AWS platform ensuring prominent Solutions for business requirements....

How AWS Skills Can Boost Your Career in The IT Industry?

India's best AWS Online Training & Certification Course By CETPA with Live Project & Avail 50% discount. Level up from creating cloud applications using AWS SDKs and to prepare for certification exams. Enroll Now!

How To Unite AWS KMS with Serverless Application Model (SAM)

AWS KMS is a Key Management Service that let you create Cryptographic keys that you can use to encrypt and decrypt data and also other keys. You can read more about it here.