-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.ts
29 lines (23 loc) · 803 Bytes
/
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
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
const bucket = new aws.s3.Bucket("3d-model-optimizer");
const image = awsx.ecr.buildAndPushImage("model-optimizer", {
context: "..",
});
const role = new aws.iam.Role("modelOptimizerRole", {
assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({
Service: "lambda.amazonaws.com",
}),
});
const attachment = new aws.iam.RolePolicyAttachment("lambdaFullAccess", {
role: role.name,
policyArn: aws.iam.ManagedPolicy.AWSLambdaExecute,
});
const optimizer = new aws.lambda.Function("optimizer", {
packageType: "Image",
imageUri: image.imageValue,
role: role.arn,
timeout: 300,
memorySize: 1536,
}, { dependsOn: [ attachment ]});
bucket.onObjectCreated("onNewModel", optimizer, { filterSuffix: ".zip" });