Created
February 8, 2019 08:08
-
-
Save mikhailshilkov/fc6af835ec4a9e2fc55b2de2353a3838 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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