AWS Lambda, please meet IOTA.

AWS Lambda and IOTA FTW!

Lewis Daly
May 16, 2018 · 4 min read

Why?

Why would we want to perform the PoW in AWS Lambda?

  • You want an easy way to provision basic resources for a service you’re writing, but want to be able to scale your resources super quick.
  • You’re using a public IOTA node that doesn’t support attachToTangle.

How do I get it working?

Three steps:

  1. yarn add iota-lambda-shim to your IOTA JS Project
  2. Add the following lines of code to shim your iota api:
const IotaLambdaShim = require('iota-lambda-shim');// Patch the current IOTA instance
IotaLambdaShim({iota, lambda, functionName});

How does it work?

Using black magic. Ok, well maybe not quite, but there’s a few cool tricks going on here.

Please, Just walk me through it!

Setting up and Deploying the Lambda

Ok! Let’s go from scratch.

$ docker --version
$ docker-compose --version
$ aws s3 ls
$ cat ~/.aws/credentials
[vessels-lewis.daly]
aws_access_key_id = *****
aws_secret_access_key = *********
export AWS_PROFILE=vessels-lewis.daly
# build the docker container
$ ./_enter_docker.sh build
# run and log into the container
$ ./_enter_docker.sh
$ echo $AWS_PROFILE
$ ./_deploy.sh
There it is!

Using the Lambda

In order to use the Lambda, we’re going to use a pretty similar approach to this. This is an example of ‘monkey patching’ the IOTA client for use with the PowBox — but it’s pretty close to what we’re trying to do.

$ yarn add iota-lambda-shim aws-sdk
//config.js
module.exports = {
provider: 'http://5.9.149.169:14265',
functionName: 'IotaProxy-dev-attHandler',
}

vessels

Digital Innovation in the Developing World

Lewis Daly

Written by

CTO of vesselstech.com | Digital Tech for Development

vessels

vessels

Digital Innovation in the Developing World