Last active
March 11, 2018 21:12
-
-
Save miensol/740d57b1f000a6be8df953799bfe42d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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