This basic tutorial shows how to install and configure Claudia.js.
- AWS account with access to IAM and Lambda
- Node.js 6 or 8
AWS Lambda currently supports Node.js 6.10 and 8.10. By default, Claudia will create 8.10 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.
Claudia is available on NPM, and the simplest way to use it is to install it as a global utility.
This will make Claudia instantly available to all your projects. Verify that Claudia was installed correctly by running the following command:
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
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
- Create an AWS profile with IAM full access, Lambda full access and API Gateway Administrator privileges.
- Add the keys to your
- Set the
AWS_PROFILEenvironment variable to
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:
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:
- AWSLambdaFullAccess is required for all Claudia deployments
- IAMFullAccess is required if you want Claudia to automatically create execution roles for your Lambda function (recommended for beginners). If you cannot use this role due to corporate policies, or do not want to grant Claudia access to IAM, then create a Lambda execution role manually, and pass the name using
--role <ROLE NAME>when executing
- AmazonAPIGatewayAdministrator is required if you want to use Claudia API Builder, Claudia Bot Builder or deploy API Gateway Proxy APIs.
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.
Since Claudia version 1.7.0, you can also use the
--profile <PROFILE_NAME> command line argument
Check out Hello-world from Lambda to create your first Lambda micro-service.