-
Notifications
You must be signed in to change notification settings - Fork 878
/
Copy pathindex.ts
61 lines (53 loc) · 1.91 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2016-2025, Pulumi Corporation. All rights reserved.
import * as aws from "@pulumi/aws";
import * as dockerBuild from "@pulumi/docker-build";
import * as pulumi from "@pulumi/pulumi";
import { lambdaSetup } from "./config";
export = async () => {
const role = new aws.iam.Role("lambdarole", {
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal(aws.iam.Principals.LambdaPrincipal),
managedPolicyArns: [
aws.iam.ManagedPolicies.AWSLambdaBasicExecutionRole,
],
});
const languages = ["dotnet", "go", "python", "typescript"];
const lambdaNames: {[key: string]: pulumi.Output<string>} = {};
lambdaSetup.map((lambda) => {
const buildLambdaCode = new dockerBuild.Image(
`${lambda.language}-build-code`,
{
push: false,
context: {
location: `./${lambda.language}-lambda`,
},
dockerfile: {
location: `./${lambda.language}-lambda/Dockerfile`,
},
exports: [
{
local: {
dest: `./dist/${lambda.language}`,
},
},
],
labels: {
created: new Date().getTime().toString(),
},
},
);
const fn = new aws.lambda.Function(
`${lambda.language}-lambda`,
{
role: role.arn,
code: new pulumi.asset.AssetArchive({
".": new pulumi.asset.FileArchive(`./dist/${lambda.language}`),
}),
runtime: lambda.runtime,
handler: lambda.handler,
},
{ dependsOn: [buildLambdaCode] },
);
lambdaNames[`lambdaNames.${lambda.language}`] = fn.name;
});
return lambdaNames;
};