Wandering through the source code for pulumi to be...
# typescript
Wandering through the source code for pulumi to better understand how I may create some custom component resources which can be used fairly opaquely in both application code and deployment code. For example just like how
will register and deploy resources when run with the cli but is also used as a reference for
in a serverless function. This is a holy grail and looking forward to seeing more of this from pulumi! My question though is around how would pulumi optimise the bundling of functions to not include all of the deployment runtime & engine? I'm wondering if the module level
export has anything to do with it and wondering how I would optimise similar code/components in user land? For additional context I have a separate process for bundling and do not want to rely on pulumi inline handlers as they may also be other runtimes (ie. not typescript->nodejs)
npm run build
and something like this in your plan:
Copy code
const lambdaFunctionArgs = {
  code: new pulumi.asset.FileArchive("./dist/app"),
  memorySize: 128,
  environment: {
    variables: {
      API_BASE_PATH: apiBasePath,
  handler: "lambdaApiHandler.handler",
  role: applicationRole.arn,
  runtime: aws.lambda.NodeJS12dXRuntime,

const lambdaFunctionApi = new aws.lambda.Function(
  { dependsOn: [applicationRole] },
Sorry that's not what I'm asking. I know how to bundle separately and reference the function as an archive but what I want is to be able to put pulumi references in the application code and have them actually together. So my application code could just reference, for example, an s3 bucket output, without having to create more indirection and push it through an env var
I use the latter strategy of passing environment variables, which helps me with local development as well. However, if I'm understanding correctly, you want to use Pulumi as a library in your application code and get outputs from a stack. For this case (and I'm not sure this is the canonical way) you can use the automation api and select the stack, and get the outputs. https://www.pulumi.com/docs/guides/automation-api/ Hints about the implementation here: https://github.com/pulumi/automation-api-examples/blob/main/nodejs/localProgram-tsnode/automation/index.ts#L23-L43 Reference docs here: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/automation/ This would presumably require a docker image for the lambda runtime to include the Pulumi CLI, as the automation API wraps it.