Skip to content

Instantly share code, notes, and snippets.

@mikhailshilkov
Created February 8, 2019 08:08
Show Gist options
  • Save mikhailshilkov/fc6af835ec4a9e2fc55b2de2353a3838 to your computer and use it in GitHub Desktop.
Save mikhailshilkov/fc6af835ec4a9e2fc55b2de2353a3838 to your computer and use it in GitHub Desktop.
export interface LambdaOptions {
readonly path: string;
readonly file: string;
readonly environment?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
}
export class Lambda extends pulumi.ComponentResource {
public readonly lambda: aws.lambda.Function;
constructor(name: string,
options: LambdaOptions,
opts?: pulumi.ResourceOptions) {
super("my:Lambda", name, opts);
const role = //... Role as defined in the last snippet
const fullAccess = //... RolePolicyAttachment as defined in the last snippet
this.lambda = new aws.lambda.Function(`${name}-func`, {
runtime: aws.lambda.NodeJS8d10Runtime,
code: new pulumi.asset.AssetArchive({
".": new pulumi.asset.FileArchive(options.path),
}),
timeout: 300,
handler: `${options.file}.handler`,
role: role.arn,
environment: {
variables: options.environment
}
}, { dependsOn: [fullAccess], parent: this });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment