When you get started with AWS Lambda
functions, you may need to use an npm package
that contains native extensions (such as C or C++). If you try to compile these packages on your development computer, then deploy that code to AWS Lambda
, it will fail because the code wasn't compiled for the environment it was deployed to.
Akiro
solves this problem by deploying a single AkiroBuilder
function to your AWS Lambda
account which compiles npm packages
for you indirectly on the architecture that the code is going to run on.AkiroBuilder Lambda
to minimize build time and prevent AWS Lambda Function Timeout
(max 300 seconds).import Akiro from "akiro";
const akiro = new Akiro({
region: "us-east-1",
bucket: "fam-akiro",
debug: 1
});
const packages = {
"flowsync": "^0.1.12",
"almaden": "^0.3.1",
"dovima": "^0.3.2",
"incognito": "^0.1.4"
};
const outputDirectory = `${process.cwd()}/node_modules_aws/`;
akiro.package(packages, outputDirectory, (packageError) => {
if (packageError) { throw packageError; }
console.log("Voila!", `ls -lah ${outputDirectory}`);
});
Akiro
requires minimal initial configuration before its automation can take over. Please read through this entire guide before attempting to use Akiro
. It may save you much grief!
The easiest way to install Akiro is through the node package manager:
npm install akiro --save-dev
There are two mandatory ways you must configure Akiro:
AWS Lambda Function
to your account.AWS IAm Role
for the AkiroBuilder Lambda Function
to save objects to AWS S3
.
AWS Lambdas
don't have a way to send back the compiled packages on their own.Akiro
saves the compiled packages to an AWS S3 Bucket
of your choice so that Akiro
can download them back to your computer.Akiro
to the AWS Regions
you will use it on.~/.aws/credentials
Due to the size of this section, we've decided to put it onto its own page. Behold, it has pictures!
AWS Lambda
called AkiroBuilder
to an AWS Region
of your choice.AkiroBuilder Lambda Function
is fundamental for the functionality of Akiro
.AWS Region
that your organization will deploy AWS Lambdas
to:import Akiro from "akiro";
const akiro = new Akiro({
region: "us-east-1",
debug: 1
});
const iamRoleName = "AWSLambda";
akiro.initialize(iamRoleName, error => {
if (error) { throw error; }
console.log("Akiro deployed.");
});
After Akiro
is configured and initialized the akiro.package()
method becomes available for everybody in the orignanization to build packages on the AkiroBuilder
.
import Akiro from "akiro";
const akiro = new Akiro({
region: "us-east-1", // Defaults to "us-east-1"
bucket: "my-akiro-bucket", // Required
debug: 1 // Comment out to run silent
});
const packages = {
"flowsync": "^0.1.12",
"almaden": "^0.3.1",
"dovima": "^0.3.2",
"incognito": "^0.1.4"
};
const outputDirectory = `${process.cwd()}/node_modules_aws/`;
akiro.package(packages, outputDirectory, (packageError) => {
if (packageError) { throw packageError; }
console.log("Voila!", `ls -lah ${outputDirectory}`);
});