high-lamp-12603
04/02/2020, 10:19 PMaws.cloudwatch.onSchedule
and new aws.lambda.Function
to create the typescript bundle. I can’t seem to get dependencies pulled in correctly. I either get errors like which could not be serialized because it was a native code function
or Could not include required dependency
. I feel like I’m missing something obviousfaint-table-42725
04/02/2020, 11:05 PMlemon-agent-27707
04/02/2020, 11:41 PMrequire
within the function to import your dependencies? For example:
https://github.com/pulumi/examples/blob/master/aws-ts-serverless-datawarehouse/datawarehouse/partitionRegistrar/index.ts#L28high-lamp-12603
04/03/2020, 1:24 AMexport const handler = async () => {
const { foo } = await import('@interal/foo');
...
};
aws.cloudwatch.onSchedule('FooFunction', 'rate(10 minutes)', handler);
Could not include required dependency '@interal/foo'
and nothing gets pulled infaint-table-42725
04/03/2020, 2:14 AM@internal/foo
? I also assume you checked that @internal/foo
does exist in your local node_modules
?lemon-agent-27707
04/03/2020, 2:54 AMrequire
all of your dependencies from within the function instead of using import
?miniature-rose-15269
04/03/2020, 2:01 PM@google-cloud/pubsub
and it’s quite a different way to write code to think to put it within the function.high-lamp-12603
04/04/2020, 12:43 AMfaint-table-42725
04/04/2020, 2:55 AMpackage.json
? If not, I believe the code that walks the tree to find your modules will stop there. If that’s the case, one thing you could try is using codePathOptions
extraIncludePaths
https://github.com/pulumi/pulumi/blob/master/sdk/nodejs/runtime/closure/codePaths.tshigh-lamp-12603
04/04/2020, 3:36 AMpackage.json
did fix the pulumi warnings but resulted in the same lambda bundle with no dependencies. For codePathOptions
are you suggesting setting extraIncludePath: $WORKSPACE_ROOT/node_modules
? I tried this but it ends up serializing the entire repos dependencies causing pulumi to hangfaint-table-42725
04/04/2020, 3:37 AM$WORKSPACE_ROOT/sub/project/package.json
(where you moved the deps)high-lamp-12603
04/04/2020, 3:38 AMfaint-table-42725
04/04/2020, 3:38 AM$WORKSPACE_ROOT/sub/project/node_modules
— the ones you moved would have those dependencies, right?high-lamp-12603
04/04/2020, 3:39 AM$WORKSPACE_ROOT/
package.json
node_modules/
...all dependencies
projects/
p1/
package.json
index.ts
Could not include required dependency
warnings. then moved all dependencies up to $WORKSPACE_ROOT/package.json
. that fixed the warnings but still nothing added to the bundlefaint-table-42725
04/04/2020, 3:42 AMPulumi.yaml
lives in p1
?high-lamp-12603
04/04/2020, 3:43 AMp1
and in the rootfaint-table-42725
04/04/2020, 3:43 AMindex.ts
lives I think actually.high-lamp-12603
04/04/2020, 3:45 AMpackage.json
at allfaint-table-42725
04/04/2020, 3:46 AMhigh-lamp-12603
04/04/2020, 3:47 AMfaint-table-42725
04/04/2020, 3:48 AMhigh-lamp-12603
04/04/2020, 3:49 AMfaint-table-42725
04/04/2020, 3:49 AMhigh-lamp-12603
04/04/2020, 3:49 AM