In part 1 of this series we learned how to write a Typescript declaration file. We’ll now learn and adapt from this tutorial to transpile code with the Typescript compiler.

Transpiling before deployment

We’ll need the Typescript compiler instead of Babel as a development dependency.

npm install tsc claudia -D

The scripts in package.json becomes what you can see below. Please not that your_profile should be replace by your AWS profile name, your_region by your target region:

"scripts": {
    "transpile": "tsc",
    "create": "tsc && claudia create --profile your_profile --region your_region --api-module dist/app",
    "update": "tsc && claudia update --profile your profile --set-env-from-json env.json",
    "destroy": "claudia destroy --profile your_profile"
  • transpile is just an alias to tsc (Typescript compiler)
  • create will transpile, then package and deploy the lambda.
  • update is used whenever your code changes and you want to redeploy it.
  • destroy, as the name implies, will remove your lambda from AWS.

You need to make sure that your AWS user is correctly privileged. It was not the case for me and I’ve been forced to manually clean an aborted deployment. May be claudia provides what’s requested but I wanted to know more about the aws-cli. So I came up with the following command lines to do the cleanup. Please replace lambda_name with the name of your lambda and your_region with your target region:

aws iam delete-role-policy --role-name lambda_name-executor --policy-name log-writer
aws iam delete-role --role-name lambda_name-executor
aws lambda delete-function --function-name lambda_name --region your_region

Final words

I have to say that the overall experience with CLAUDIA.JS is absolutely deligthfull. Thanks to the developers of this amazing toolkit. They are always listening on gitter and will promptly respond to your answers. It was very helpfull to me.

That’s all folks.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.