sparse-intern-71089
04/21/2023, 9:40 AMbrave-planet-10645
04/21/2023, 9:45 AMCallbackFunction
has the same inputs as a lambda function. So you can set vpcConfig (https://www.pulumi.com/registry/packages/aws/api-docs/lambda/function/#vpcconfig_nodejs) in the same waybrave-planet-10645
04/21/2023, 9:47 AMlambda.Function
insteadhelpful-winter-64866
04/21/2023, 9:50 AMlambda.Function
instead? How do I transpile my code?brave-planet-10645
04/21/2023, 9:51 AMpulumi up
helpful-winter-64866
04/21/2023, 9:52 AMdry-pilot-49577
04/21/2023, 11:22 PMimport * as awsnative from "@pulumi/aws-native";
export const lambdaStore = new awsnative.s3.Bucket("lambda_artifacts", {
// note: do not rename a bucket
// <https://github.com/pulumi/pulumi-aws-native/issues/584>
bucketName: "s3.lambda.artifacts",
accessControl: "Private",
versioningConfiguration: {
status: "Enabled",
},
lifecycleConfiguration: {
rules: [
{
id: "keepLastX",
status: "Enabled",
noncurrentVersionExpiration: {
// keep last 10, even if a service isn't touched for a while
newerNoncurrentVersions: 10,
// keep anything from last 30 days
noncurrentDays: 30,
},
},
],
},
});
lambda/provisioned-graphql.ts (relevant lines)
import * as pulumi from "@pulumi/pulumi";
import * as awsnative from "@pulumi/aws-native";
import * as aws from "@pulumi/aws";
import { lambdaStore } from "../../services/s3.js";
const LAMBDA_NAME = "graphql-prov";
const file = new aws.s3.BucketObjectv2(LAMBDA_NAME, {
bucket: lambdaStore.id,
key: `${LAMBDA_NAME}.zip`,
source: new pulumi.asset.FileArchive(
"./artifacts/lambdas/graphql-public.zip"
),
});
export const fn = new awsnative.lambda.Function(LAMBDA_NAME, {
role: role.arn,
memorySize: 128,
architectures: ["arm64"],
runtime: "nodejs16.x",
handler: "index.handler",
code: {
s3Bucket: lambdaStore.id,
s3Key: file.key,
s3ObjectVersion: file.versionId,
},
});
Moving to a bundled zip meant I could use esbuild etc to bundle the lambda properly. It adds a few extra steps, but you gain easy rollbacks via s3 versioning and a bit more control over the conversion from ts to js.No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by