Skip to content

Instantly share code, notes, and snippets.

@miensol
Last active March 11, 2018 21:12
Show Gist options
  • Save miensol/740d57b1f000a6be8df953799bfe42d1 to your computer and use it in GitHub Desktop.
Save miensol/740d57b1f000a6be8df953799bfe42d1 to your computer and use it in GitHub Desktop.
import cloudform, { Lambda, IAM, Fn } from 'cloudform';
import { FunctionProperties } from 'cloudform/types/lambda/function';
import { readFileSync } from 'fs';
const LambdaExecutionRole = 'LambdaExecutionRole', Alice = 'Alice', Bob = 'Bob';
function lambdaFunction(functionCode: string, options?: Partial<FunctionProperties>) {
return new Lambda.Function({
Code: { ZipFile: functionCode },
Handler: "index.main",
Role: Fn.GetAtt(LambdaExecutionRole, "Arn"),
Runtime: "nodejs6.10", ...options
});
}
export default cloudform({
Resources: {
[Alice]: lambdaFunction(readFileSync('Alice.js', 'utf-8'), {
Environment: {
Variables: { BobFunction: Fn.GetAtt(Bob, "Arn") }
}
}),
[Bob]: lambdaFunction(readFileSync('Bob.js', 'utf-8')),
... // LambdaExecutionRole see below
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment