Installing and configuring Claudia.js

This basic tutorial shows how to install and configure Claudia.js.


AWS Lambda currently supports Node.js 8.10 and 10.x runtimes. By default, Claudia will create 10.x functions in Lambda. (You can force an older version with the --runtime argument while creating the function).

Although you can use a later version of Node to run tools on your machine, this might cause compatibility issues after deployment. To avoid nasty surprises, we strongly suggest using the same version for development and deployments. You can use nvm to manage multiple versions of Node on your development environment.

Installing Claudia.js

Claudia is available on NPM, and the simplest way to use it is to install it as a global utility.

npm install claudia -g

This will make Claudia instantly available to all your projects. Verify that Claudia was installed correctly by running the following command:

claudia --version

Installing as a project dependency

Alternatively, you can set up Claudia.js as a local project dependency. This allows you, for example, to easily distribute the tool with your project, so other developers don’t have to install it separately. It is also a good option if you work on a system that is locked down and prevents you from installing a global utility using NPM.

Claudia is a deployment tool, so it does not introduce any runtime dependencies — so install it as a development dependency using -D or --save-dev.

npm install claudia -D

In this case, you can run Claudia from node_modules/.bin/claudia in your project directory, and using NPM scripts. Check out Setting up package.json for easy deployment for more information on that option.

Configuring access credentials

Lazy quick-start

  1. Create an AWS profile with IAM full access, Lambda full access and API Gateway Administrator privileges.
  2. Add the keys to your .aws/credentials file
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_ACCESS_SECRET
  1. Set the AWS_PROFILE environment variable to claudia

Detailed info about credentials

Claudia just uses the Node.js API for AWS, without any magic. If you already have the access keys set up for the AWS command line or the Node.js API, Claudia will just use your default profile.

If you’ve never set up AWS command line tools or the Node.js API, just follow the instructions in Setting AWS Credentials for NodeJS section of the AWS API guide.

On most systems, this will effectively mean adding the access keys to .aws/credentials in your home directory:

aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_ACCESS_SECRET

If you do not want to use the access credentials for the main user account, but want to set up a separate user account for Claudia, assign the following roles to the user:

Selecting the AWS profile to use with Claudia

The AWS Node.js API allows you to configure multiple profiles, and restrict access or use different AWS accounts for various projects. Following the principle of least privileges, we recommend creating a separate profile with write-access to Lambda, API Gateway and IAM, and using that for deployment. You can create different profiles for testing, that will have limited access to AWS resources, without being able to access IAM.

There are several ways to select the active profile, and the complete list is in the Setting AWS Credentials for NodeJS guide on AWS.

Although any approach described in the guide will work, the easiest is to set the AWS_PROFILE environment variable.

AWS_PROFILE=deployment claudia <options>

Since Claudia version 1.7.0, you can also use the --profile <PROFILE_NAME> command line argument

Where next?

Check out Hello-world from Lambda to create your first Lambda micro-service.

Did you like this tutorial? Get notified when we publish the next one.

Once a month, high value mailing list, no ads or spam. (Check out the past issues)