akiro v0.0.12

Akiro.js

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.
Akirosolves this problem by deploying a singleAkiroBuilderfunction to yourAWS Lambdaaccount which compilesnpm packagesfor you indirectly on the architecture that the code is going to run on.- Packages are built in parallel using multiple invokes of the same
AkiroBuilder Lambdato minimize build time and preventAWS Lambda Function Timeout(max 300 seconds). - After the packages are built, they are automatically saved to an S3 bucket of your designation, then optionally downloaded and unzipped to a local directory.
- Built-in support for local caching so that any specific version of any package is only built once and then re-used to optimize deployment times. This greatly optimizes deployment speeds!
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}`);
});Getting Started
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!
Installation
The easiest way to install Akiro is through the node package manager:
npm install akiro --save-devConfiguration
There are two mandatory ways you must configure Akiro:
- Setup your own AWS Credentials so that you can deploy an
AWS Lambda Functionto your account. - Setup an
AWS IAm Rolefor theAkiroBuilder Lambda Functionto save objects toAWS S3.- This is required because
AWS Lambdasdon't have a way to send back the compiled packages on their own. - Instead,
Akirosaves the compiled packages to anAWS S3 Bucketof your choice so thatAkirocan download them back to your computer.
- This is required because
- Initialize
Akiroto theAWS Regionsyou will use it on.
1. Setup Your Own ~/.aws/credentials
- Akiro expects there to be an ~/.aws/credentials file.
- For more information on how to set up this file, read this guide.
- In the future, we will add support for specifying credentials manually in other ways. * Please submit an issue if you urgently require a different method.
2. Setup an AWS IAm Role For AkiroBuilder
Due to the size of this section, we've decided to put it onto its own page. Behold, it has pictures!
3. Initialize Akiro
- Initializing deploys an
AWS LambdacalledAkiroBuilderto anAWS Regionof your choice. - The
AkiroBuilder Lambda Functionis fundamental for the functionality ofAkiro. - Akiro only needs to be initialized once per
AWS Regionthat your organization will deployAWS Lambdasto: - This process will be simplified in later BETA releases.
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.");
});Building Packages
After Akiro is configured and initialized the akiro.package() method becomes available for everybody in the orignanization to build packages on the AkiroBuilder.
akiro.package(packageList, outputDirectory, callback)
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}`);
});