Has anyone created a Lambda Layer with a typescrip...
# typescript
s
Has anyone created a Lambda Layer with a typescript class? For example say i have a seperate class i've created that i want to be reused across multiple lambdas something like:
Copy code
class myAwesomeClass {
  ... cool options here
}
awesome.ts
Then when creating my layer referencing it like:
Copy code
const awesomeLayer = () => new aws.lambda.LayerVersion('my-lambda-version', 
{
  code: new pulumi.asset.AssetArchive({
    '.': new pulumi.asset.FileArchive('./awesome.ts'),
  }),
  compatibleRuntimes: [
    aws.lambda.NodeJS12dXRuntime,
    aws.lambda.NodeJS10dXRuntime,
  ],
  layerName: 'awesome_layer'
}, providerOpts);
The issue it that obviously the typescript file wont run in the lambda, is there a way that pulumi can compile this to normal JS? Or have i missed something?
c
You’ll need to “build” your awsomeness using
tsc
first. Then use the build path, usually
bin
or
dist
to reference the js file.
👍 1
s
Is there not a way that pulumi can do it using the built in typescript support?
c
No,
Pulumi
is a runtime, not a compiler, afaik.